Fixes for invite to subgroup

[QA needed] 

- Re-enable invite to subgroup
- Change how groups tree is built so parents of orphaned subgroups are included.
- Change how leave group works: when you leave a parent group, it will only leave the subgroups if the parent is hidden