diff --git a/quadratic-client/src/shared/components/ShareDialog.tsx b/quadratic-client/src/shared/components/ShareDialog.tsx index 8013096660..670d39e78d 100644 --- a/quadratic-client/src/shared/components/ShareDialog.tsx +++ b/quadratic-client/src/shared/components/ShareDialog.tsx @@ -648,6 +648,13 @@ function ManageUser({ let activeRole = user.role; let error = undefined; + // If the user's role is being updated, show the optimistic value + if (fetcherUpdate.state !== 'idle' && isJsonObject(fetcherUpdate.json)) { + activeRole = fetcherUpdate.json.role as (typeof roles)[0]; + } else if (fetcherUpdate.data && !fetcherUpdate.data.ok) { + error = 'Failed to update. Try again.'; + } + const label = useMemo(() => getRoleLabel(activeRole), [activeRole]); // If user is being deleted, hide them @@ -658,13 +665,6 @@ function ManageUser({ error = 'Failed to delete. Try again.'; } - // If the user's role is being updated, show the optimistic value - if (fetcherUpdate.state !== 'idle' && isJsonObject(fetcherUpdate.json)) { - activeRole = fetcherUpdate.json.role as (typeof roles)[0]; - } else if (fetcherUpdate.data && !fetcherUpdate.data.ok) { - error = 'Failed to update. Try again.'; - } - return (