Refactored new getAutomaticGroups() function out of getEffectiveGroups()