List Buddypress Groups Of Current Logged In User

<?php
    /* Is the user in any teams */
    $user_id =get_current_user_id();
    $args = array(
    'user_id' => $user_id
    );
    if ( bp_has_groups( $args) ) :
  ?>

    
    <ul>

    <?php while ( bp_groups() ) : bp_the_group(); ?>

      <li>
        <div class="t-m-list">
          <a href="<?php bp_group_permalink(); ?>"><?php bp_group_avatar( 'type=full' ); ?>
          <h5><?php bp_group_name(); ?></h5>
          </a>
        </div>
      </li>

    <?php endwhile; ?>

    </ul>
    

  <?php else: /* If the user is not in any teams */?>

      <p>No teams</p>

  <?php endif; ?>

Returns a list of the groups the current logged in user is a member of

Source: https://bp-tricks.com/snippets/display-buddypress-groups-based-specific-id/