Can’t see private posts on the frontend if logged in and have the correct capability

As default, WordPress allows you to see private posts if your role is an admin, the author of the post, or if have the right permissions. However, with ElasticPress, we faced some issues that made us not mimic the behavior in the ElasticPress plugin.

The major reason for this decision is the feature called Protected Content, which lets you index posts with private status into ElasticSearch. It is important to note that Protected Content is not enabled by default, because you may or may not want your private content to be indexed. The feature may also include private post status in the autosuggest feature if you have it enabled, so keep that in mind.

If you still want to include private posts in your query, you may use the pre_get_posts hook like this:

PHP
add_action( 'pre_get_posts', function( $query ) {
    if ( current_user_can( 'edit_others_posts' ) ) {
        $query->set( 'post_status', 'desired_post_statuses' );
    }
});