Hello - the way out is to
ExtractSrf the faces all around the edge and Join them into the ‘correct’ sets:
Join everything back up. You may or may not always get a valid solid arrangement though - here it looks like you will - these are all four-surface non manifolds that can be split into two pairs.
Looks like you may still end up with some reversed faces though… (= invisible in shaded views) The right way to build this is not to have zero-thickness in a single solid - ether leave a small gap the these coincident edges or have them fully intersect, and trim/Boolean them.