I believe there is a bug in GetBoundFor that might exaggerate the problems with sorting: the Ymin and Ymax overwrite the previous error instead of adding to it.
If I'm not mistaken, ConvertToLayerRelative is supposed to modify the transform's Z offset in place. Here, that modification is being lost in a temporary.
Yes, that is intentional. Since we are temporarily looking at the Z/Y sorting stuff, we don't want to flatten everything down to layers, which is what it would do if we passed the actual Z there.
Once we're ready to deal with the layers again, we'll remove the temporary.