From this community post:
Expand Grouped Layers by Default
I have modified the out of the box widget for 1.17:
Highest level group layer expanded by default
Change the map search to a filter icon and say Filter Layers with filter text open by default

Tick boxes or eyes collapse or expand layers automatically
Supports regular widget options
