diff --git a/workflow.module b/workflow.module
index 0b92eb14a1a064b41ff4e25c06ffff3002eace88..72b70b54b30532a907d36457a0465114877b6d1c 100644
--- a/workflow.module
+++ b/workflow.module
@@ -1,4 +1,7 @@
 <?php
+use Drupal\Component\Utility\Html;
+use Drupal\user\Entity\Role;
+use Drupal\user\RoleInterface;
 
 /**
  * @file
@@ -307,17 +310,27 @@ function workflow_execute_transition(WorkflowTransitionInterface $transition, $f
  *   Array of role names keyed by role ID, including the 'author' role.
  */
 function workflow_get_user_role_names($permission) {
-  static $roles = NULL;
-  if ($roles && isset($roles[$permission])) {
-    return $roles[$permission];
+  static $role_names = NULL;
+  if (isset($role_names[$permission])) {
+    return $role_names[$permission];
   }
 
   // Copied from AccountForm::form().
-  $roles[$permission] = array_map(['\Drupal\Component\Utility\Html', 'escape'],
-    [WORKFLOW_ROLE_AUTHOR_RID => '(' . t(WORKFLOW_ROLE_AUTHOR_NAME) . ')']
-    + user_role_names(FALSE, $permission));
+  if (version_compare(\Drupal::VERSION, '10.2', '>=')) {
+    $roles = Role::loadMultiple();
+    $roles = array_map(fn(RoleInterface $role) => Html::escape($role->label()), $roles);
+  }
+  else {
+    // @phpstan-ignore-next-line
+    $roles = user_role_names(FALSE, $permission = NULL);
+  }
+
+  $author_label = '(' . t(WORKFLOW_ROLE_AUTHOR_NAME) . ')';
+  $author_roles = [WORKFLOW_ROLE_AUTHOR_RID => Html::escape($author_label)];
+
+  $role_names[$permission] = $author_roles + $roles;
 
-  return $roles[$permission];
+  return $role_names[$permission];
 }
 
 /**