Why get_user_by() doesn’t work in my code?

I tweaked your code to make sure the $email was defined before attempting to process. I stop where the problem may be. If you follow all the if and else code, the “continue”resident when an email address is NOT a part of a particular group (subscriber, admin, customer etc) will skip the processing and move onto the next email. Thus your call may not be called and thus you will not get a result back.

I also added some important filters to your form entry at the top of the code snippet.

The only other path, is if the email is not defined.

 public function bulk_add_users() 
    {
     if ( isset( $_GET['action'] ) && 'bulk-add-users' === $_GET['action'] && isset( $_GET['group-id'] ) ) {
         $group_id       = sanitize_text_field(absint( $_GET['group-id']) );
         $first_names    = sanitize_text_field($_REQUEST['first_name']);
         $last_names     = sanitize_text_field($_REQUEST['last_name']);
         $emails         =  filter_var($_REQUEST['email'], FILTER_VALIDATE_EMAIL);  
         $error_results  = [];
         $insert_results = [];

        if ( $emails ) 
         {
           $role = apply_filters( 'uo-groups-user-role', get_option( 'default_role', 'subscriber' ) );
             foreach ( $emails as $k => $email ) 
            {
             if ( ! empty( $email ) ) 
               {
               if ( is_email( $email ) )
                  {
                   $first       = $first_names[ $k ];
                   $last        = $last_names[ $k ];
                   $email       = sanitize_email( $email );
                   $is_existing = email_exists( $email );
                   if ( is_numeric( $is_existing ) ) 
                     {
                     $user_id     = $is_existing;
                      $user_groups = learndash_get_users_group_ids( $user_id, true );

                      // THE POTENTIAL SKIP IS HERE. IF THE EMAIL IS NOT IN THE GROUP
                      if ( in_array( $group_id, $user_groups ) ) 
                      {
                      $error_results[] = sprintf( __( 'Line #%d: %s is existing user of group.', 'uncanny-learndash-groups' ), $k + 1, $email );

                      //*************IF YOU CONTINUE HERE, IT IS POSSIBLE TO NEVER REACH YOUR CODE
                       continue;     
                      }  // if ( in_array( $group_id, $user_groups ) 

                    //-------------------------------------
                    // Go here only if the email is in the group
                     $user_data = array(
                             'user_email' => $email,
                             'user_id'    => $user_id,
                             'first_name' => $first,
                             'last_name'  => $last,
                            'role'       => $role,
                        );
                    if ( isset( $user_data['first_name'] ) && ! $is_existing )
                      update_user_meta( $user_id, 'first_name', $user_data['first_name'] );

                    if ( isset( $user_data['last_name'] ) && ! $is_existing ) 
                            update_user_meta( $user_id, 'last_name', $user_data['last_name'] );

                        $restApi = new RestApiEndPoints();
                        $restApi->add_existing_user( $user_data, false, $group_id, 0, 'not redeemed', false );




                }   //  if ( is_numeric( $is_existing ) )
              else 
                {
                 $user_data = array(
                 'user_login' => $email,
                 'user_email' => $email,
                 'first_name' => $first,
                 'last_name'  => $last,
                 'role'       => $role,
                 'group_id'   => $group_id,
                 );
                 $restApi   = new RestApiEndPoints();
                 $restApi->add_invite_user( $user_data, false, false, false );

               } //  if ( is_numeric( $is_existing ) ) 

                $insert_results[] = sprintf( __( '%s added & invited successfully.', 'uncanny-learndash-groups' ), $email );


                //------------YOUR ADDED CODE
                // Not ever reached on a continue or if the email is not defined in the form
                 global $wpdb;

              $user_id_for_um_groups = get_user_by( 'email', $email );
              $current_group_id_for_um_groups = $wpdb->get_var("SELECT ID FROM wpso_posts WHERE post_excerpt = $group_id");
              $current_user_id_for_um_groups = get_current_user_id();
              $wpdb->insert( 'wpso_um_groups_members', array( 
              'group_id' => $current_group_id_for_um_groups,
              'user_id1' => $user_id_for_um_groups,
              'user_id2' => $current_user_id_for_um_groups,
              'status' => 'approved',
              'role' => 'member') );
             //----------- YOUR END OF ADDED CODE
              } 
            else
              $error_results[] = sprintf( __( 'Line #%d: Email (%s) not correct.', 'uncanny-learndash-groups' ), $k + 1, $email );

             }     // if ( is_email( $email ) ) 
          }        //  if ( ! empty( $email ) ) 
        }          //  foreach ( $emails as $k => $email ) 
     }            // if ( $emails ) 


      .............................
   } // public function bulk_add_users()