Get users by display name on reference autocomplete field
A potentially cleaner/easier way to do that would be to leverage the JSON API.  After you install that module, you should able to make a call to the /jsonapi/user/user endpoint (see the "GET user accounts section on https://www.drupal.org/docs/8/modules/json-api/fetching-resources-get), and parse out the UIDs into the array.