Impossible to set visibility for GameObjects with hideFlags.HideInHierarchy

I want to have an object visible in the hierarchy, but hide its children. This is easily doable. But then, if I set the visibility (aka, the little eye icon), its children don’t disappear.

So I tried code. But it seems like it’s impossible to set the visibility via code for objects that are hidden in the hierarchy.

In other words, this code doesn’t work:

gameObject.hideFlags = HideFlags.HideInHierarchy;
SceneVisibilityManager.instance.Hide(gameObject, false);

As in, the object is hidden in the hierarchy but still visible in the scene.

Is there a way to do what I’m thinking?

Hiding a parent using the eye icon hides its children for me, is this option not enabled for you?
image
(the eye icon in this image)

Normally yes, and I expected it to work that way.
But apparently the hideFlags make it impossible for the children to disappear.