I think as a user the expected behavior is that whether children collections or objects are visible or not (grayed out) shouldn't affect parent collection visible state. Only his own "disable in viewports" and "hide in viewport" options and his parent's should be taken into account. And the same for other states.
For example when you create an empty collection is visible (non grayed out) even when it doesn't have any visible child.
In the patch I removed the part that takes into account children flags which provoked LAYER_COLLECTION_VISIBLE_VIEW_LAYER flag not being set in lc->runtime_flag when all children collections where not visible (layer_collection_sync eval only children collections flags, children objects flags are eval later out of this function).
lc->runtime_flag is used later by the outliner code to check if the tree element should be visible or not and then draw it as grayed out or not.