Programmatically Create an Array of User Objects and Print in Twig Template MYMODULE.module:

function MYMODULE_preprocess_node(&amp;$variables) {

    if ($variables['node']-&gt;bundle() == 'content_type') {

        $currentUserUID = \Drupal::currentUser()-&gt;id();
        $recipients = $variables['node']-&gt;get('field_user_reference')-&gt;getValue();
        $userList = array();

        foreach ($recipients as $recipient) {

            if ($recipient['target_id'] != $currentUserUID) {
                $userList[] = \Drupal\user\Entity\User::load($recipient['target_id']);
            }

        }

        if ($variables['node']-&gt;getOwnerId() != $currentUserUID) {
            $userList[] = \Drupal\user\Entity\User::load($variables['node']-&gt;getOwnerId());
        }

        $variables['userList'] = $userList;

    }

}


FILENAME.twig.html:

{{ userList | render }}




I've also tried working with: 

$recipients = $variables['node']-&gt;get('field_user_reference')-&gt;view('compact');


and tried to filter the UID in the if statement inside the foreach.



My goal is to gather all users referenced from field_user_reference, and add the owner of the node, while filtering out the currentUser() into a single array. I then need to render that array in a twig template file as a user display mode. In this instance, compact.

I am not sure if my impasse lies in twig rendering, or better preprocessing.

How do you render a preprocessed user object in a twig template file? 



Notes:

$recipients = $variables['node']-&gt;get('field_user_reference')-&gt;view('compact');


does render out the referenced users in the compact view mode, however I cannot seem to filter out the current user with something like $recipient-&gt;uid[0]-&gt;target_id != $currentUserUID.
Before you can render a list of entities you have to build a render array:

$variables['userList'] = \Drupal::entityTypeManager()
  -&gt;getViewBuilder('user')
  -&gt;viewMultiple($userList, 'compact');


Now Twig is able to render the entities:

{{ userList }}    


You don't need |render, because Twig renders arrays automatically.