can't collapse something inside a box

Hi, I’ve been programming a website and
I created a box which appears when you press a button → that works fine

but then
inside the box there are certain text elements;

Each text is a different one; those who says ‘text’ are dynamic and the other are each one a different text.
So if there’s nothing on the ‘VFX’ data, then I want the ‘VFX’ text to collapse instead of the ‘VFX:’ and empty space.
But it doesn’t work

this is my code

export function dynamicDataset_ready() {
const item = $w(“#dynamicDataset”).getCurrentItem();

//Add your code for this event here:

if (item[“gallery”] === undefined) $w(“#group2”).collapse();
else $w(“#group2”).expand();
if (item[“Client”] === undefined) $w(‘#groupclient’).collapse();
else $w(‘#groupclient’).expand();
}

(groupclient is the group conformed of both ‘Client:’ and the dynamic text)
(group2 is a gallery, and that works as well).

So what am I missing there?