diff --git a/core/modules/views/src/Plugin/views/field/Field.php b/core/modules/views/src/Plugin/views/field/Field.php
index c4003b4..a79b313 100644
--- a/core/modules/views/src/Plugin/views/field/Field.php
+++ b/core/modules/views/src/Plugin/views/field/Field.php
@@ -820,10 +820,17 @@ public function getItems(ResultRow $values) {
         'settings' => $this->options['settings'],
         'label' => 'hidden',
       ];
-      // Some bundles might not have a specific field, in which case the faked
-      // entity doesn't have it either.
-      $entity = $this->createEntityForGroupBy($this->getEntity($values), $values);
-      $build_list = isset($entity->{$this->definition['field_name']}) ? $entity->{$this->definition['field_name']}->view($display) : NULL;
+      // optional relationships do not provide an entity at all. So we can't use
+      // createEntityForGroupBy() for those rows.
+      $entity = $this->getEntity($values);
+      if ($entity) {
+        // Some bundles might not have a specific field, in which case the faked
+        // entity doesn't have it either.
+        $entity_group_by = $this->createEntityForGroupBy($entity, $values);
+        $build_list = isset($entity_group_by->{$this->definition['field_name']}) ? $entity_group_by->{$this->definition['field_name']}->view($display) : NULL;
+      } else {
+        $build_list = NULL;
+      }
     }
 
     if (!$build_list) {
