Based on @jamio answer if you want to hide the nav menus based on their class you can use `classes[0] ` instead of `title` so that can you now just add a class on menu instead on setting each menu thru code

  

     add_filter( 'wp_nav_menu_objects', 'remove_menu_items', 10, 2 );
    function remove_menu_items( $items, $args ) {
    
        $logged_in = is_user_logged_in();
    
        foreach ( $items as $item_index => $item ) {
            // Remove "Downloads" menu item when not logged in
            if ( $item->classes[0] == 'hide_when_logout' ) {
                if ( !$logged_in ) {
                    unset($items[$item_index]);
                }
            }
        }
        return $items;
    }