How to load a css file depending on the current role

Your if check can result of a php notice because not logged in users have no roles and in that case $user->roles[0] will output notice: array offest (in short).

Aside from that, have you checked your console network to see if /assets/css/b2bstyle.css was loaded, even if you see status 404 you are in the right direction.

Your code seems to be correct, apart from the if check.

I would suggest doing something like this

function testCss () {
    // get user
    $user = wp_get_current_user();
    
    // check if user has the following roles (administrator OR b2b)
    if (in_array('administrator', $user->roles) || in_array('b2b', $user->roles)) {
        wp_enqueue_style('jupiterx-child', get_stylesheet_directory_uri() . '/assets/css/b2bstyle.css');
    }
}
add_action('wp_enqueue_scripts', 'testCss', 11);

If you check your console and go to network and see something like this

enter image description here

Click on it to reveal more information about the request, under Headers -> General, the very first line show you the request url, check to see that that is the correct one

enter image description here

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)