Improve linear descendant scopes
When querying for descendants of multiple groups, we construct a SQL query that includes a join. This query is fine until the number of groups becomes large. We can remove the join by aggregating all of the ids from the base query.