Use get_cat_ID to retreive multiple category IDs

$category_in = array();
foreach($topicsofinterest as $topicofinterest){

    //Chaneg 'category' to the taxonomy name.
    $term = get_term_by( 'name', $topicofinterest, 'category');
    
    $category_in[] = $term->term_id;
}

Just curious, why don’t you store the category ID instead of category name in user meta?