Thanks to @Thiago_Mobilon I’ve found the issue and have a proposed fix
https://github.com/discourse/discourse/pull/36785