I would generally recommend not to have any useless settings. Useless settings are useless in my opinion. Just don’t have them, because they have no use whatsoever. By definition, actually. ![]()
Else than that, you could use an application handler to check the state of the input and then control hide_in_modifier properties of the inputs.
In order not to have to script everything every time, you could have some rules about what inputs are checkboxes for “collapsible tabs” and what inputs are items to be collapsed.
So I would use the description of the inputs. If the description contains the words “Toggle tab” it would be the toggle input and then the items that belong to it should contain it’s name followed by " ->" and description (so that it’s always unique because “My tab” would later be found in “My tab 2” as well, but “My tab ->” fixes that).

That’s the code. I added add-on stuff, so you could save it as .py file and install as add-on if you wanted:
bl_info = {
"name": "Modifier collapsable inputs",
"author": "Martynas Žiemys",
"version": (1, 0),
"blender": (3, 5, 1),
"location": "",
"description": "If input description contains 'Toggle tab' is a toggle input and the items that belong to it must contain it's name followed by ' ->' in the description",
"warning": "",
"doc_url": "",
"category": "Modifiers",
}
import bpy
from bpy.app.handlers import persistent
@persistent
def GN_collapse_handler(dummy):
tabs = []
items = []
for mod in bpy.context.object.modifiers:
if mod.type != 'NODES':
continue
for input in mod.node_group.inputs:
if "Toggle tab" in input.description:
tabs.append(input)
else:
items.append(input)
for item in items:
for tab in tabs:
if tab.name+" ->" in item.description:
item.hide_in_modifier = not mod[tab.identifier]
def register():
bpy.app.handlers.depsgraph_update_post.append(GN_collapse_handler)
def unregister():
bpy.app.handlers.depsgraph_update_post.remove(GN_collapse_handler)
if __name__ == "__main__":
register()
Not sure if I am unregistering the handler correctly. That shouldn’t end the world though.