diff --git a/modules/ggroup/src/Graph/SqlGroupGraphStorage.php b/modules/ggroup/src/Graph/SqlGroupGraphStorage.php
index 8ed28e17b..0a2756a50 100644
--- a/modules/ggroup/src/Graph/SqlGroupGraphStorage.php
+++ b/modules/ggroup/src/Graph/SqlGroupGraphStorage.php
@@ -143,6 +143,7 @@ protected function loadGroupMapping($gid) {
       $groups[] = $gid;

       // Build the cache tags for all of the (deduped) groups.
+      $groups = $this->flattenGroups($groups);
       $groups = array_unique($groups, SORT_NUMERIC);
       $cache_tags = [];
       foreach($groups as $group_id) {
@@ -162,6 +163,21 @@ protected function loadGroupMapping($gid) {
     $this->loaded[$gid] = TRUE;
   }

+  private function flattenGroups($groups) {
+    $flat_groups = [];
+    if (!empty($groups)) {
+      foreach ($groups as $group_val) {
+        if (is_array($group_val)) {
+          $flat_groups += $group_val;
+        }
+        else {
+          $flat_groups[] = $group_val;
+        }
+      }
+    }
+    return $flat_groups;
+  }
+
   /**
    * Gets the edge ID relating the parent group to the child group.
    *
diff --git a/modules/ggroup/src/GroupRoleInheritance.php b/modules/ggroup/src/GroupRoleInheritance.php
index 2b597f5dc..a8312e1da 100644
--- a/modules/ggroup/src/GroupRoleInheritance.php
+++ b/modules/ggroup/src/GroupRoleInheritance.php
@@ -84,13 +84,13 @@ public function getAllInheritedGroupRoleIds($group_id) {
     $cache = $this->cache->get($cid);
     if ($cache && $cache->valid) {
       $this->roleMap[$group_id] = $cache->data;
-      return $this->roleMap;
+      return $this->roleMap[$group_id];
     }

     $this->roleMap[$group_id] = $this->build($group_id);
     $this->cache->set($cid, $this->roleMap[$group_id], Cache::PERMANENT, ['group:' . $group_id]);

-    return $this->build($group_id);
+    return $this->roleMap[$group_id];
   }

   /**
@@ -259,6 +259,7 @@ protected function getSubgroupRelationConfig($group_id, $subgroup_id) {
       $group_contents = $this->entityTypeManager->getStorage('group_content')
         ->loadByProperties([
           'type' => array_keys($subgroup_relations_config),
+          'gid' => [$group_id],
         ]);
       foreach ($group_contents as $group_content) {
         $this->subgroupRelations[$group_content->gid->target_id][$group_content->entity_id->target_id] = $group_content->bundle();
