Why is GUILayout such a Pain in the @#$@# in Nested OnGUI Conditionals?

I had a nice layout with GUILayout, until I decided to just coalesce several menu’s together in the same scene, instead of using a scene to load the menu’s. Errors galore:

Getting control 0’s position in a group with only 0 controls when doing Repaint
Getting control 1’s position in a group with only 0 controls when doing Repaint
(etc)

I ended up having to convert all my GUILayout’s to GUI’s.

This brings me to ask the rhetorical question: Why are GUILayout’s such a pain in the @#@#?

Your code is the pain in the a not GUILayout
you pretty surely change the state of the gui or some gadgets with update or fixed update which is a big no go.

you can change states in ongui itself or in late update, but never in update / fixed update that can run between the various calls to ongui (ongui is called once per event, with a gui like what you might have here going by the description, you get it called several dozen times per frame)

the easiest thing to do is: don’t use it.
write an own flexible routine for the layouting thats opted for your purpose and you are fine.