I tested it on 3.4, 3.5 and 3.6 - same result everywhere, here's the .blend file
I have a two Render layers in my scene. One Layer have a Grease Pencil object with "Line Art" modifier that is pointing to a collection. With this two layers setup, I have a node tree in the compositor that have a Alpha Over node with those two layers connected and factor depending on "Greater than" of Depth (Z) passes of each render layer (See screen).
The problem is that if two objects that are in the line art collection, are too far away in the "depth" axis - the line art is drawn over the objects from another layer, even if it's further away.
I made a simple scene that shows the issue, you can find it in the attachment
render if objects within the collection are far away:
and this is how it looks when I move the object closer to each other (but it is still in front of the large box (See animation)
So - my question is - is this a bug or expected behavior? Is there anything I can do to prevent this behavior and make grease pencil to respect the Z pass as it does when the objects are close together?