CORE-4907: Modified queries to take into account the groups that a user is in.