Or more precisely, if the closest scrollable of the anchor and the closest scrollable of the overlay are the same. This is a regression from https://gerrit.wikimedia.org/r/#/c/276664/ (for T129521). The culprit is this.needsCustomPosition = closestScrollableOfContainer !== closestScrollableOfFloatable;. This is plainly false, because (like in our case) the floatable can be in an overlay at (0,0) while the container is somewhere else, in which case positioning is definitely needed, but depending on the scrollbar situation the closest scrollable container could be the window for both of them.
This caused T130153: [betalabs] Regression: 'Mark as read/unread' box is misplaced in Echo, where I worked around it by ensuring the anchor was in an always-scrollable container.
The demo doesn't expose this, because it only tests overlays with dialogs where there are several layers of scrollables separating the anchor from the overlay. https://gerrit.wikimedia.org/r/277931 adds a demo that exposes the broken behavior.