Thank you!
I think I'm doing something wrong with my setup because it is turning off visibility for only one. I tried it with the text and path in groups and not in groups. Do I need them to be their own layer?
This is before running the script, shapes visible, text box hidden:

after running the script only Shape-B-6 is hidden, but the others are visible:

Aha, it's because of my rookie mistake. It was showing the stuff it hid!
But now, it goes through layers, only worries about the Groups, which should be faster by leaving alone the nested shape. It pre-hides all the groups in the layer, then turns on just the ones we need!
Try this:
function test () {
var doc = app.activeDocument;
var shapeNamesFrame = doc.textFrames.getByName("shape-names");
var shapeNameArray = shapeNamesFrame.contents.split(/,/g);
for (var i = 0; i < doc.layers.length; i++) {
var layer = doc.layers[i];
for (var k = 0; k < layer.groupItems.length; k++) {
var groupItem = layer.groupItems[k];
groupItem.hidden = true;
}
for (var j = 0; j < shapeNameArray.length; j++) {
var name = shapeNameArray[j];
for (var k = 0; k < layer.groupItems.length; k++) {
var groupItem = layer.groupItems[k];
if (groupItem.name === name) {
groupItem.hidden = false;
}
}
}
}
}
test();