Fix getGroupsForPrincipal so it does not crash if no position