This patch fixes a dumb error in D5595, as reported here: https://developer.blender.org/rB6d37654ce8e0d442741d284bb36536aa75078c33
In a nutshell I am not properly checking both ends of the common edge to see if joining can proceed.
So for example in the case of two areas that are side-by-side horizontally. The code was properly checking that the shared edge shared exact X position. But then only checked how close the bottom Y positions were. This needed to check the closeness of the top Y positions of the shared edge as well. Otherwise we can have a situation, as reported where a join could be attempted even though the top of their shared edge was wildly different, if the bottom was close.
Doh. Fixed and tested in all situations and directions.