When two layers in the map point to the same feature class and the first feature layer has a definition query assigned, querying related records for the second layer also works based on the definition query.
The issue is no longer reproducible when map services are published from ArcGIS Pro. With two layers related to another, map services report multiple relationships for each combination which helps resolve this issue.