protected function getGroups() {
    $types = [];
    /** @var \Drupal\group\Entity\GroupType $group_type */
    foreach (GroupType::loadMultiple() as $group_type) {
      // We can only select group types that have the 'join group'
      // permission enabled.
      if (in_array('join group', $group_type->getOutsiderRole()->getPermissions())) {
        $types[] = $group_type;
      }
    }
    return $types;
  }