Which hook to use to detect new members added to group?
this works:
function tm_mymodule_group_content_presave(Drupal\group\Entity\GroupContent $entity) {
  $group_content_type = $entity-&gt;getGroupContentType();
  if ($group_content_type-&gt;get('content_plugin') == 'group_membership') {    
    $groupid = $entity-&gt;gid-&gt;getValue()[0]['target_id'];
    $userid = $entity-&gt;entity_id-&gt;getValue()[0]['target_id'];
    $group = \Drupal::entityTypeManager()-&gt;getStorage('group')-&gt;load($groupid);
    $user = \Drupal::entityTypeManager()-&gt;getStorage('user')-&gt;load($userid);
    $membership = $group-&gt;getMember($user);
    $roles = $membership-&gt;getRoles();

     // Do something
   }
}