This is fixed on master and 1.x.x. Thanks for reporting.
I filed a feature request recently, asking for hierarchical groups (for the full description see: https://github.com/NodeBB/NodeBB/issues/7410).
I completely understand this request may not help everyone, and perhaps its not considered something that should be added to the core.
To that end, does anyone have an idea how to efficiently implement the above in a plugin? I am trying to avoid multiple accesses to the DB, and obviously redundant c/p. How would you go about implementing that?