I would use the tag to solve this problem. Most people don't know this exists and I have no idea why. You would probably have to rewrite the html so it no longer uses tables but I don't really consider that to be a negative. I would also question why we are saving collapsed comments. I feel like this is something that doesn't need to be persisted forever. If you want this behavior why not use local storage instead?
Persisting it on the server allows users to browse on multiple devices and keep their collapse settings in sync. This is useful in particular for long threads of comments, where collapsing can be used as a tool to keep track of progress through the thread by collapsing comments along the way.
Is this the expected behavior when you collapse or show a thread? I would suggest that it is not, as most minor interactions on a page are only stored locally.
How many people actually use this feature? In order get a benefit from this feature you have to be logged into hacker news on multiple devices, collapse a thread on one device, come back to that thread later on the second device and then continue reading from where you left off. Alternatively you can just scroll past the stuff you've already read, which has a minimal cost to the user.
The benefits seem negligible for the amount of developer time that likely went into making this feature.