Index: core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php	(revision aabfc7cc0051e17e27de6985a1ac6bc226529124)
+++ core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php	(revision dea063cb3808a392c221152b02a678ff997dd81a)
@@ -127,6 +127,20 @@
     // Store the selection settings in the key/value store and pass a hashed key
     // in the route parameters.
     $selection_settings = isset($element['#selection_settings']) ? $element['#selection_settings'] : [];
+
+    // Put entity into settings.
+    $form_object = $form_state->getFormObject();
+    if (isset($form_object)) {+
+      if(method_exists($form_object, 'getEntity')) { $entity = $form_object->getEntity(); };
+      if (isset($entity)) {
+        $storage = $form_state->getStorage();
+        if (isset($storage['group'])) {
+          $entity->parent_group = $storage['group'];
+        }
+        $selection_settings['entity'] = $entity;
+      }
+    }
+
     $data = serialize($selection_settings) . $element['#target_type'] . $element['#selection_handler'];
     $selection_settings_key = Crypt::hmacBase64($data, Settings::getHashSalt());
 
Index: core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php	(revision aabfc7cc0051e17e27de6985a1ac6bc226529124)
+++ core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php	(revision dea063cb3808a392c221152b02a678ff997dd81a)
@@ -43,6 +43,25 @@
    * {@inheritdoc}
    */
   public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
+    // Add form object to field definition.
+    $field_definition = $items->getFieldDefinition();
+
+    // Put entity into settings.
+    $form_object = $form_state->getFormObject();
+    if (isset($form_object)) {
+      if(method_exists($form_object, 'getEntity')) { $entity = $form_object->getEntity(); };
+      if (isset($entity)) {
+        $storage = $form_state->getStorage();
+        if (isset($storage['group'])) {
+          $entity->parent_group = $storage['group'];
+        }
+
+        $setting = $field_definition->getSetting('handler_settings');
+        $setting['entity'] = $entity;
+        $field_definition->setSetting('handler_settings', $setting);
+      }
+    }
+
     // Prepare some properties for the child methods to build the actual form
     // element.
     $this->required = $element['#required'];
Index: core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php	(revision aabfc7cc0051e17e27de6985a1ac6bc226529124)
+++ core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php	(revision dea063cb3808a392c221152b02a678ff997dd81a)
@@ -153,7 +153,7 @@
    */
   public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
     $display_name = $this->getConfiguration()['view']['display_name'];
-    $arguments = $this->getConfiguration()['view']['arguments'];
+    $arguments = $this->handleArgs($this->getConfiguration()['view']['arguments']);
     $result = [];
     if ($this->initializeView($match, $match_operator, $limit)) {
       // Get the results.
@@ -183,7 +183,7 @@
    */
   public function validateReferenceableEntities(array $ids) {
     $display_name = $this->getConfiguration()['view']['display_name'];
-    $arguments = $this->getConfiguration()['view']['arguments'];
+    $arguments = $this->handleArgs($this->getConfiguration()['view']['arguments']);
     $result = [];
     if ($this->initializeView(NULL, 'CONTAINS', 0, $ids)) {
       // Get the results.
@@ -222,4 +222,46 @@
     $form_state->setValueForElement($element, $value);
   }
 
+  /**
+   * Handles replacing tokens in arguments for views.
+   *
+   * Replaces tokens using Token::replace.
+   *
+   * @param array $args
+   *   An array of arguments that may contain tokens.
+   *
+   * @return array
+   *   The arguments to be sent to the View.
+   */
+  protected function handleArgs($args) {
+    $token_service = \Drupal::token();
+    $options = array(
+      'clear' => TRUE,
+    );
+
+    $data = array();
+    if (isset($this->configuration['handler_settings']['entity'])) {
+      $entity = $this->configuration['handler_settings']['entity'];
+      $entity_type = $entity->getEntityTypeId();
+      if (!isset($data[$entity_type])) {
+        $data[$entity_type] = $entity;
+      }
+    }
+
+    if (isset($this->configuration['entity'])) {
+      $entity = $this->configuration['entity'];
+      $entity_type = $entity->getEntityTypeId();
+      if (!isset($data[$entity_type])) {
+        $data[$entity_type] = $entity;
+      }
+    }
+
+    // Replace tokens for each argument.
+    foreach ($args as $key => $arg) {
+      $args[$key] = $token_service->replace($arg, $data, $options);
+    }
+
+    return $args;
+  }
+
 }
