I'd always kind of wondered how we got away with not updating EquivalenceClasses during join removal, and the answer evidently is that we can't anymore. I've not tried to write a patch yet.
I wondered about that too, and I thought that the target rel could not be mentioned in any EC, otherwise join_is_removable should have noticed that this rel is used above the join and thus decided that the join is not removable. Hence there is no need to update ECs during join removal. Apparently this is not right, as shown by this issue.
I went ahead and drafted a patch as attached. But I'm not sure if it suffices to only update ec_relids, em_relids and ec_sources as the patch does. Also I'm wondering if any of them would become empty after the update.