Hide comments from admin comments.php that user can’t edit or manage

I found another piece of code on the internet which I have modified to work.

add_filter('the_comments', 'edit_comments_filter_comments');

function edit_comments_filter_comments($comments){
    global $pagenow;

    $currentuserid = get_current_user_id();

    if($pagenow == 'edit-comments.php' && !current_user_can('edit_others_posts')){
        foreach($comments as $i => $comment){
            $the_post = get_post($comment->comment_post_ID);
            if($comment->user_id != $currentuserid  && $the_post->post_author != $currentuserid)
                unset($comments[$i]);
        }
    }
    return $comments;
}

As I understand it, this takes the comments pulled in by the query and checks them before displaying them.

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino