Add " (replace)" after each name of the layer group and then Filters > Animation > Optimize (for GIF). It’ll open up a new file with all the groups merged and set up for a “combine” type gif. You can then export as gif and have your animation without having flattened your source file.
I find the easiest way to do all the latter is to have " (replace)" (including the space) on your clipboard, then triple-click the layer you want to change the name of to the right of the text. First click selects, second click edits the text, and third moves the cursor to the end of the text so you can Ctrl+V in your " (replace)" and save flattening your file.