--> Hide Properties? <--

IDetailLayoutBuilder incorrectly reports properties as visible when they have been hidden and more importantly refuses to hide “inner properties” (meta ShowOnlyInnerProperties). What is wrong with my code??

	auto HidePropertiesRecursive = [&DetailBuilder](auto&& HidePropertiesRecursive, const FString& InPropertyName, const UClass* InContainerClass) -> bool {
		if (!IsValid(InContainerClass))) {
			// Irrelevant.
			return false;		
		}

		TSharedRef<IPropertyHandle> PropHandleX = DetailBuilder.GetProperty(FName(InPropertyName), InContainerClass);

		CUR_LOG(LogCorePluginEditor, VeryVerbose, "%s: Attempt hide for: %s.", *InContainerClass->GetName(), *InPropertyName);
		if (PropHandleX->HasMetaData(TEXT("ShowOnlyInnerProperties"))) {
			CUR_LOG(LogCorePluginEditor, VeryVerbose, "Recurse into inner property.");

			uint32 OutNum = 0;
			PropHandleX->GetNumChildren(OutNum);
			for (uint32 i = 0; i < OutNum; i++) {
				TSharedPtr<IPropertyHandle> PropY = PropHandleX->GetChildHandle(i);
				if (!PropY->GetProperty()) {
					return false;
				}
				
				if (// Must recurse into the property on the same parent first.
					!HidePropertiesRecursive(HidePropertiesRecursive, PropY->GetProperty()->GetNameCPP(), InContainerClass)
					// Attempt to search inner property on parent class.
					&& !HidePropertiesRecursive(HidePropertiesRecursive, PropY->GetProperty()->GetNameCPP(), InContainerClass->GetSuperClass())
					) {
					return false;
				}
			}

			// Success if we reach this point.
			return true;
		}

		// If we did not have to recurse into an inner property, we can try to hide it.

		DetailBuilder.HideProperty(PropHandleX);

		if (DetailBuilder.IsPropertyVisible(PropHandleX)) {
			// Still visible (failure). Try on the parent class. We must have an exact match where the property was declared.
			return HidePropertiesRecursive(HidePropertiesRecursive, InPropertyName, InContainerClass->GetSuperClass());
		}

		// Success.
		return true;
	};

Logs

Attempt hide for: ThatProperty.
SomeClass: Attempt hide for: ThatProperty.
Recurse into inner property.
SomeClass: Attempt hide for: SomeInnerProperty.
SomeParentClass: Attempt hide for: SomeInnerProperty.
SomeParentClass: Attempt hide for: SomeInnerProperty.

After returning false on the initial call for ThatProperty:
Could not hide the property: ThatProperty.

Turns out this is not enough

DetailBuilder.HideProperty(MyPropHandle);

if

MyPropHandle->HasMetaData(TEXT("ShowOnlyInnerProperties"))

You have to browse through it recursively and hide the inner properties too.

Additionally it seems you can only find the property handle on the exact UClass it was declared on.