@davidb can you take a peek at this one?
It sounds similar to what you’re working on here, but I’m not sure it’s the exact same issue:
https://github.com/discourse/discourse/pull/33543
I did a quick test myself, and it does look like the PR fixes this.