LPS-43611 Move roles and owner filtering to the inner query