How to auto-accept a friend-request in buddypress based on user meta

UPDATE

try this

function bp_auto_accept_friend_request( $friendship_id, $friendship_initiator_id, $friendship_friend_id ) {
        $friendship_status = BP_Friends_Friendship::check_is_friend( $friendship_initiator_id, $friendship_friend_id );
        if ( 'not_friends' == $friendship_status ) {
            if ( is_user_expert( $friendship_friend_id ) ) {
            // force add
            friends_add_friend( $friendship_initiator_id, $friendship_friend_id, true );
            friends_accept_friendship( $friendship_id );
        }
        }
    }
    add_action('friends_friendship_requested', 'bp_auto_accept_friend_request', 200, 3);

this way we only call friends_add_friend function with $force = true if they are not friends yet.