Fix sqls to avoid duplicate joins, and so group members can see other groups