KM macro fails 2nd run because can't reset dialog state

Then try this instead:

const theDiv = document.querySelectorAll('[data-index="4"]');
return (theDiv[0].getAttribute("data-expanded"));

It's the reverse of previous, so true means the Cell properties are visible:

data-index might be more stable than id.