How to check if a user is logged in inside a view
I managed to accomplish this task by creating my own custom view field plugin

in mymodule.views.inc I used

function mymodule_views_data() {

  $data['views']['table']['group'] = t('Current User');
  $data['views']['table']['join'] = [
    // #global is a special flag which allows a table to appear all the time.
    '#global' =&gt; [],
  ];

  $data['views']['logged_in'] = [
    'title' =&gt; t('Logged In'),
    'help' =&gt; t('Check if user is logged in'),
    'field' =&gt; [
      'id' =&gt; 'logged_in',
    ],
  ];

  return $data;
}


and then in /mymodule/src/Plugins/views/field/LoggedIn.php I had

&lt;?php

namespace Drupal\mymodule\Plugin\views\field;

use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;

/**
 * A handler to provide a field that is completely custom by the administrator.
 *
 * @ingroup views_field_handlers
 *
 * @ViewsField("logged_in")
 */
class LoggedIn extends FieldPluginBase {

    /**
     * {@inheritdoc}
     */
    public function init(ViewExecutable $view, DisplayPluginBase $display, array &amp;$options = NULL) {
        parent::init($view, $display, $options);
        $this-&gt;field_alias = 'logged_in';
    }

    /**
     * {@inheritdoc}
     */
    public function usesGroupBy() {
        return FALSE;
    }

    /**
     * {@inheritdoc}
     */
    public function query() {
        // Do nothing -- to override the parent query.
    }

    /**
     * {@inheritdoc}
     */
    protected function defineOptions() {
        $options = parent::defineOptions();

        return $options;
    }

    /**
     * {@inheritdoc}
     */
    public function render(ResultRow $values) {

        $logged_in = \Drupal\mymodule\Modules\CurrentUser::isLoggedIn();
        return $logged_in;
    }

}


Some of the contents of LoggedIn.php might not be necessary (not 100% sure) I was using another module as an example.