Show tracks with corresponding groups

Hello guys i have a question. Since its possible in the visibility tab to show the tracks that are connected to a channel, i wanted to ask if this would be possible.

I have a template with 9 groups (DRUMS,PERCUSSION,VOCALS,etc.) with corresponding group tracks. I made a macro which made it possible to view the active tracks within a folder and the corresponding group track. Now the problem is when i create a subgroup for my kicks for example it always shows it when i activate the macro, although there are currently no tracks routed to it. What i wanted to do is:

If i enable the macro, show all the tracks that have data in the drums folder, show all the groups that these tracks are sending to (for example if there are tracks routing to the kick bus show the kick bus, if not then dont show it), show the drums group, a group called ALL DRUMS (which i made possible to show with the macro i have) and the mixbus. Same for Keys for example (show tracks within keys - subgroups that have receives - keys group - all music)

I hope that i made it possible to understand and maybe someone knows a hack that can make this possible. Thank you for your help !