The main question actually I have is why do you need to use JS for that? There’s nothing in your post that explain your case.

You can already show and hide group using native Bubble actions