Conditional editing CPT – using editor’s role and author’s usermeta

I manage to filter the posts, this seems to be enough for this project

function remove_notallowed_authors( $query ) {
    $user = wp_get_current_user();

    if ( in_array( 'editor_group_role', (array) $user->roles ) ) {
        $user_ids = get_users( [
            'role'   => 'user_role_that_posted',
            'fields' => 'ID'
        ] );

        $query->set( 'author__in', $user_ids );
    }
    
}
add_action( 'pre_get_posts', 'remove_notallowed_authors' );