App icon indicating copy to clipboard operation
App copied to clipboard

[$250] WS settings - Invite member from WS settings then clicking on it gives error in RHP

Open applause-bot[bot] opened this issue 4 months ago • 26 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.4.32-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: N/A Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Windows 11 / Chrome App Component: Workspace Settings

Action Performed:

  1. Open staging.new.expensify
  2. Go to any WS settings > Members
  3. Click on invite member
  4. Add member
  5. Click on added member

Expected Result:

Right hand panel should not show error message.

Actual Result:

Right hand panel shows error message.

Workaround:

Unknown

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [ ] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [ ] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/286f463b-d296-4bd6-814d-e1fe8c82334b

View all open jobs on GitHub

Applause Internal Information Exported by: Svetlana Lazutkina Bug ID: 7203901

Upwork Automation - Do Not Edit

applause-bot[bot] avatar Jul 09 '26 16:07 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/887f5e6f8f91cfaf835f64e04d3aa73ddd3e6dc56d7bec531ab8c422ad57af90

applause-bot[bot] avatar Jul 09 '26 16:07 applause-bot[bot]

Proposal

Please re-state the problem that we are trying to solve in this issue.

Inviting a new member from Workspace Settings › Members, then immediately clicking that just-added member row, opens the member-details RHP as a "Hmm... it's not here" not-found page instead of the member's details. Reproducible in staging and production on v9.4.32-0.

What is the root cause of that problem?

The member-details RHP resolves the member through a fragile two-hop lookup that is keyed off the route's accountID:

  1. accountID → personalDetails[accountID].login → employeeList[login]

The two Onyx stores are keyed differently — policy.employeeList is keyed by login/email, while personalDetails is keyed by accountID — so the page must bridge them via personalDetails[accountID].login. If that bridge breaks, member is undefined and the page renders NotFoundPage.

For a brand-new invitee, the accountID in play is a client-generated optimistic hash of the email (generateAccountID(email)). When the invite API call succeeds, the optimistic personalDetails[optimisticAccountID] entry is cleaned up (set to null in finallyData) and the backend returns the real personal details under a different, real accountID. If the RHP was opened with the now-stale optimistic accountID (or the optimistic→real swap races the click), personalDetails[accountID] is undefined → memberLogin is '' → member = employeeList[''] is undefined → shouldShowNotFoundPage is true.

Code references (App @ 65a29b3)

Note on regression scope: the not-found condition and lookup logic in this file are ~2 years old (unchanged since 2024), so the file itself did not regress. Because the bug newly surfaced in v9.4.32, the trigger is most likely an upstream data-population/timing change — the recent "personal details → useOnyx" migration series and the Member.ts onyx-store PR that was reverted on 2026-07-09. This part should be confirmed by an internal engineer before landing a fix.

What changes do you think we should make in order to solve the problem?

Make the RHP resilient to the optimistic→real accountID transition so a pending/just-invited member never falls through to the not-found page:

  • In WorkspaceMemberDetailsPage.tsx:97-99, don't depend solely on personalDetails[accountID].login to resolve the member. Add a fallback that resolves the login for the route accountID directly from the policy (e.g., reverse-map via getMemberAccountIDsForWorkspace(policy?.employeeList) — which the members list already uses to navigate — and pick the login whose accountID matches the route param). This keeps member resolvable even while personalDetails[accountID] is momentarily null.
  • Guard shouldShowNotFoundPage (:275-280) so it does not trigger for a member that is still pendingAction: 'add' (invite in flight).

What alternative solutions did you explore?

Alternatively, fix it at the source by ensuring the members-list navigation and the details-page lookup key off the same stable identifier during the optimistic window — either navigate with the login/email rather than the transient optimistic accountID, or keep the optimistic personalDetails[optimisticAccountID] entry until the real entry is confirmed rather than nulling it in finallyData.

Related issues

  • Expensify/App#91649 — "It's not here" screen shown in member RHP after removal (same not-found path, different trigger).

Next Steps for Contributor+ team: To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/95725) to create a draft PR. To refine: @MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.

⚠️ Medium confidence — the root-cause mechanism is code-supported, but the exact regression window (recent useOnyx personal-details migration) needs runtime confirmation before implementing.

MelvinBot avatar Jul 09 '26 16:07 MelvinBot

Proposal

Please re-state the problem that we are trying to solve in this issue.

When we invite a brand-new user from Workspace settings > Members and then click on that member, the member details RHP opens correctly for a moment and then turns into the "Hmm... it's not here" (not found) page, even though the member was added successfully.

What is the root cause of that problem?

When we invite an email that has no existing personal details record, the app creates an optimistic personal detail keyed by a locally generated optimistic accountID, and registers a cleanup for it that runs when AddMembersToWorkspace succeeds, because the backend returns the same user under their real accountID:

https://github.com/Expensify/App/blob/3b9779a55f20ce9f2d31937b81ffecd057d1c8a2/src/libs/PersonalDetailsUtils.ts#L354-L360

That cleanup is pushed into the command's successData here:

https://github.com/Expensify/App/blob/3b9779a55f20ce9f2d31937b81ffecd057d1c8a2/src/libs/actions/Policy/Member.ts#L919-L925

The members list maps each employee's email to an accountID through the personal details list, so clicking the just-invited member navigates to WORKSPACE_MEMBER_DETAILS with the optimistic accountID in the route. WorkspaceMemberDetailsPage then resolves everything from that route param:

https://github.com/Expensify/App/blob/3b9779a55f20ce9f2d31937b81ffecd057d1c8a2/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L97-L99

When the AddMembersToWorkspace response lands (that's the moment the panel flips in the repro video), the optimistic personal detail is set to null and the member now only exists under their real accountID. The already-open RHP still has the stale optimistic accountID in its route, so memberLogin resolves to '', member becomes undefined, and the page falls into the not-found branch permanently:

https://github.com/Expensify/App/blob/3b9779a55f20ce9f2d31937b81ffecd057d1c8a2/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L276-L281

What changes do you think we should make in order to solve the problem?

In WorkspaceMemberDetailsPage, when the route's accountID stops resolving to a login (the optimistic record was just cleaned up), re-resolve the member's real accountID from the login we were already displaying and point the route at it. PersonalDetailsUtils.getKnownAccountIDByLogin is exactly suited for this since it only returns accountIDs that actually exist in personal details and never fabricates optimistic ones:

const prevMemberLogin = usePrevious(memberLogin);

useEffect(() => {
    // Once AddMembersToWorkspace succeeds, the optimistic personal detail is cleared and the member
    // only exists under their real accountID, so re-resolve it from the login we were showing.
    if (memberLogin || !prevMemberLogin) {
        return;
    }
    const realAccountID = getKnownAccountIDByLogin(prevMemberLogin);
    if (!realAccountID || realAccountID === accountID) {
        return;
    }
    Navigation.setParams({accountID: String(realAccountID)});
}, [memberLogin, prevMemberLogin, accountID]);

usePrevious is already used in this page and getKnownAccountIDByLogin just needs to be added to the existing @libs/PersonalDetailsUtils import. Updating the param in place keeps the RHP mounted, re-renders it with the member's real data, and means any page opened from here (role, custom fields, profile) also receives the real accountID. If the member was genuinely removed, the login lookup fails and the not-found page still shows as before.

What specific scenarios should we cover in automated tests to prevent reoccurrence of this issue?

  • Render WorkspaceMemberDetailsPage for a freshly invited member (optimistic accountID in the route, optimistic personal detail and employeeList entry in Onyx), then apply the success reconciliation (optimistic personal detail nulled, real accountID entry added, pendingAction cleared) and assert the page updates the route to the real accountID and keeps showing the member details instead of the not-found page.
  • Assert the not-found page still renders when the member is actually removed from the policy's employeeList.

What alternative solutions did you explore? (Optional)

  • Resolving the login by reverse lookup instead of usePrevious: the optimistic accountID is a deterministic hash of the login (generateAccountID), so the page could scan policy.employeeList for an email whose generated ID matches the route accountID and redirect to the real one. This would additionally cover refreshing/deep-linking a stale optimistic URL, but it scans the employee list and adds a dependency on how optimistic IDs are generated; the targeted fix above covers the reported flow more simply.
  • Keeping the optimistic personal detail around until the real record arrives (dropping the cleanup from successData). Rejected: the cleanup exists precisely to avoid duplicate personal detail entries once the backend returns the real accountID.
  • Disabling the member row while the invite is still pending (similar to how optimistic participants are disabled elsewhere). This avoids the race but blocks admins from opening a member they just added even when online, which is a worse experience than fixing the page itself.

David-2002065 avatar Jul 09 '26 16:07 David-2002065

Proposal

Please re-state the problem that we are trying to solve in this issue.

On Web (Windows/Chrome, staging & production), after inviting a member from Workspace Settings > Members and then clicking the newly-added row, the Right Hand Panel opens WorkspaceMemberDetailsPage and renders the NotFound error page instead of the member's details. Expected: the RHP should show the member's details without any error.

What is the root cause of that problem?

WorkspaceMemberDetailsPage resolves the member by chaining accountID → personalDetails[accountID].login → policy.employeeList[login] at src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:97-99. For a just-invited member, the row in WorkspaceMembersPage (src/pages/workspace/WorkspaceMembersPage.tsx:300) navigates with the invitee's accountID, but the optimistic Onyx data written by addMembersToWorkspace / buildAddMembersToWorkspaceOnyxData populates policy.employeeList keyed by login while personalDetails[accountID] for that new invitee is not yet available. That makes memberLogin an empty string at line 98, member = policy.employeeList[''] becomes undefined at line 99, so shouldShowNotFoundPage at lines 276-277 is true and the NotFoundPage at line 280 is rendered inside the RHP.

What changes do you think we should make in order to solve the problem?

  1. In src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:98-99, fall back to locating the employee by scanning policy.employeeList for an entry whose accountID matches the route accountID when personalDetails?.[accountID]?.login is empty — this covers the optimistic window where personalDetails hasn't populated yet.
  2. Alternatively (or additionally), at src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:276-277, only treat the page as NotFound after a short optimistic grace period when personalDetails[accountID] is missing but accountID is present in policy.employeeList values, so freshly-invited members don't briefly render the error page.
  3. In src/libs/actions/Policy/Member.ts (buildAddMembersToWorkspaceOnyxData, called from addMembersToWorkspace at line 976), ensure the optimistic Onyx data also writes a minimal personalDetails[accountID] = { login, accountID, ... } entry for each newly invited member so the reverse lookup on the details page succeeds immediately after invite.
  4. Verify WorkspaceMembersPage.openMemberDetails at src/pages/workspace/WorkspaceMembersPage.tsx:292-304 passes the same accountID that is written into the optimistic personalDetails from step 3 (from invitedEmailsToAccountIDs), so the two ends of the lookup agree.

What alternative solutions did you explore? (Optional)

aswin-s avatar Jul 09 '26 16:07 aswin-s

Proposal

Please re-state the problem that we are trying to solve in this issue.

After inviting a member from Workspace Settings → Members, clicking the just‑added (still‑optimistic) member opens the member details RHP, which then flips to a "page not found" error.

What is the root cause of that problem?

Just‑invited members are rendered optimistically in the members table, and their row is clickable when it should not be.

WorkspaceMembersPage builds each row with an isInteractive flag specifically meant to block interaction while the member's personal details are optimistic:

src/pages/workspace/WorkspaceMembersPage.tsx:384

isInteractive: !details.isOptimisticPersonalDetail,

But the row component ignores it and hardcodes interactive, so the optimistic row is always tappable:

src/components/Tables/WorkspaceMembersTable/WorkspaceMembersTableRow.tsx:56-65

<Table.Row
    interactive            // ← hardcoded; item.isInteractive never used
    disabled={item.disabled}
    onPress={item.action}
>

(Note disabled is computed only from DELETE/errors — WorkspaceMembersPage.tsx:394 disabled: isPendingDeleteOrError — so it is false for an ADD-optimistic member. isInteractive is the intended gate, and Table.Row already honors !interactive to suppress onPress — src/components/Table/TableRow.tsx:156.)

The consequence: openMemberDetails (WorkspaceMembersPage.tsx:292-304) navigates to WORKSPACE_MEMBER_DETAILS using the optimistic accountID. For a brand‑new invitee this ID is the synthetic hash from getUserToInviteOption → generateAccountID(login) (src/libs/PersonalDetailOptionsListUtils/index.ts, src/libs/UserUtils.ts:216), not a real account.

WorkspaceMemberDetailsPage resolves the member via that accountID:

src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:97-99

const accountID = Number(route.params.accountID);
const memberLogin = personalDetails?.[accountID]?.login ?? '';
const member = policy?.employeeList?.[memberLogin];

While optimistic, the page renders fine. But when the invite request succeeds, the optimistic personal detail is wiped: getPersonalDetailsOnyxDataForOptimisticUsers emits finallyData with personalDetails[accountID] = null (Onyx merge‑delete), applied in buildAddMembersToWorkspaceOnyxData (src/libs/actions/Policy/Member.ts:919-920). The real member lands under a different accountID. The details page (which receives personalDetails reactively) re‑renders: personalDetails[accountID] is now undefined → memberLogin = '' → member is undefined → shouldShowNotFoundPage = !member fires (WorkspaceMemberDetailsPage.tsx:276-281) → NotFoundPage, the error shown. Because the route param is pinned to the deleted optimistic accountID, the error persists.

This is why it reproduces on the freshly added member: the user clicks it during the optimistic window, and the cleanup on success strands the open page on a dead accountID.

What changes do you think we should make in order to solve the problem?

Wire the already‑computed flag to the row so optimistic members are not clickable until their personal details are real.

  1. Add the field to the row type — src/components/Tables/WorkspaceMembersTable/index.tsx:25-41:
type WorkspaceMemberRowData = TableData & {
    accountID: number;
    ...
    isInteractive: boolean;   // add
    action: () => void;
    dismissError: () => void;
};
  1. Consume it in src/components/Tables/WorkspaceMembersTable/WorkspaceMembersTableRow.tsx:58:
<Table.Row
    interactive={item.isInteractive}
    ...

Now an isOptimisticPersonalDetail member renders as non‑interactive; once success replaces the optimistic detail with the real one (isOptimisticPersonalDetail cleared), isInteractive becomes true and the row is tappable, navigating with the real accountID. No changes to navigation or the details page are needed.

trasnake87 avatar Jul 09 '26 16:07 trasnake87

Proposal

What is the root cause of that problem?

After a member is invited from Workspace Settings > Members, the newly added row is rendered optimistically before the backend confirms the invite and assigns a real accountID. Clicking that row navigates to the member details RHP, which is keyed by the member's accountID from the route. For a just-invited member the details page tries to resolve the member from policy.employeeList and the matching personal details, but the optimistic entry does not yet have a resolvable accountID/personal details record, so the page falls into its NotFound/error state instead of showing member details.

Part of the render path also runs the invited login through formatPhoneNumber, which calls parsePhoneNumber. When the invited value is a brand-new login that does not yet exist in personal details, the lookup returns nothing usable and the RHP has no valid member object to display:

https://github.com/Expensify/App/blob/65a29b386da45e27b75afd624415f29aff457640/src/libs/LocalePhoneNumber.ts#L20-L50

https://github.com/Expensify/App/blob/65a29b386da45e27b75afd624415f29aff457640/src/libs/PhoneNumber.ts#L14-L60

The gap: the member row is clickable and navigates by accountID before that accountID is valid, so the RHP cannot find the member and shows an error.

What changes do you think we should make in order to solve the problem?

  1. In the workspace member details flow, guard resolution of the invited member so an optimistic (not-yet-confirmed) member does not route to an error. When the member cannot be resolved by accountID, fall back to matching by their optimistic login in policy.employeeList rather than treating it as NotFound.

  2. Ensure the phone/display formatting used for the invited member does not fail when personal details are missing. formatPhoneNumber already returns the raw string when parsePhoneNumber is not valid, so the fix is to pass the invited login through this path only after confirming a member object exists:

https://github.com/Expensify/App/blob/65a29b386da45e27b75afd624415f29aff457640/src/libs/LocalePhoneNumber.ts#L20-L50

const memberLogin = policyMember?.email ?? invitedLogin;
const displayName = memberLogin ? formatPhoneNumber(memberLogin) : '';
  1. Until the invite is confirmed and a valid accountID exists, either keep the row non-navigable or route using the optimistic login so the RHP always has a member to render, removing the error state.

What alternative solutions did you explore? (Optional)

Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

samranahm avatar Jul 09 '26 16:07 samranahm

🚨 Edited by proposal-police: This proposal was edited at 2026-07-09 16:40:27 UTC.

Proposal

What is the root cause of that problem?

For a brand-new invitee, the workspace invite picker creates a client-side optimistic accountID from the typed login, and the invite flow stores that accountID in the invite draft that is later passed to addMembersToWorkspace. https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/libs/PersonalDetailOptionsListUtils/index.ts#L120-L128 https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/pages/workspace/DynamicWorkspaceInvitePage.tsx#L189-L198

addMembersToWorkspace then writes the optimistic member into policy.employeeList keyed by login and writes an optimistic personalDetails entry keyed by that generated accountID. On success, it also cleans up that optimistic personal detail because the backend is expected to provide the real personal detail under the real accountID. https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/libs/actions/Policy/Member.ts#L845-L846 https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/libs/actions/Policy/Member.ts#L859-L920 https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/libs/PersonalDetailsUtils.ts#L347-L375

The members page already knows optimistic personal details are not stable and sets isInteractive: !details.isOptimisticPersonalDetail, but the table row ignores that flag and always passes interactive to Table.Row. This lets the user open the just-added optimistic member row with the temporary accountID. https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/pages/workspace/WorkspaceMembersPage.tsx#L371-L397 https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/Tables/WorkspaceMembersTable/WorkspaceMembersTableRow.tsx#L56-L64

Once the optimistic personal detail is cleaned up, the already-open details RHP is still on /workspaces/:policyID/members/:accountID with the temporary accountID. WorkspaceMemberDetailsPage derives the member only from personalDetails[accountID].login, so that lookup becomes empty, policy.employeeList[''] is undefined, and the RHP renders NotFoundPage. The video shows this exact timing: the member details first render, then the same route flips to "Hmm... it's not here" without a new navigation. https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L97-L100 https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L276-L280

What changes do you think we should make in order to solve the problem?

First, wire the existing optimistic-row guard through the table. Add isInteractive to WorkspaceMemberRowData and pass interactive={item.isInteractive} from WorkspaceMembersTableRow so rows backed by optimistic personal details are not clickable until the real member data is available. https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/Tables/WorkspaceMembersTable/index.tsx#L25-L41 https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/components/Table/TableRow.tsx#L155-L160

Second, make WorkspaceMemberDetailsPage resilient for an RHP that is already open when the optimistic accountID is cleaned up. Keep the last non-empty member login/details for the current route, and when personalDetails[accountID] disappears but that previous login still exists in policy.employeeList, resolve the real accountID with getKnownAccountIDByLogin(previousLogin) and replace the current member details route with the real accountID. Until that replacement happens, keep rendering from the previous login/details instead of treating the valid workspace member as not found. Preserve the existing not-found behavior when the member is actually removed from policy.employeeList or is pending delete. https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/libs/PersonalDetailsUtils.ts#L258-L271 https://github.com/Expensify/App/blob/db11bf0ce4414ecf0d61e9adaddee7bf8e1459ef/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L97-L132

Test coverage:

  • Add a unit/component test that renders the member details RHP with an optimistic accountID, then applies the success reconciliation where the optimistic personal detail is removed and the real personal detail is added, and assert the page keeps showing the member instead of NotFoundPage.
  • Add coverage that the details page replaces or navigates to the real accountID once getKnownAccountIDByLogin(previousLogin) can resolve it.
  • Add a table-row test or workspace members test proving an isOptimisticPersonalDetail row receives interactive={false} and does not call openMemberDetails.
  • Keep a regression assertion that an actually removed member still renders the not-found page.

What alternative solutions did you explore? (Optional)

We could change the member details route to include the member login instead of only accountID, but that widens the route contract and every nested member RHP route would need to be updated.

We could also keep the optimistic personal detail around after success, but that cleanup exists to avoid duplicate personal details once the backend returns the real accountID.

Only disabling optimistic rows would prevent the easiest repro, but it would not recover an RHP that was already opened before the success cleanup landed. The details page still needs the stale-route recovery to avoid flipping from a valid member panel to not-found.

KJ21-ENG avatar Jul 09 '26 16:07 KJ21-ENG

Triggered auto assignment to Contributor-plus team member for initial proposal review - @daledah (External)

melvin-bot[bot] avatar Jul 09 '26 16:07 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~022075255901660443019

melvin-bot[bot] avatar Jul 09 '26 16:07 melvin-bot[bot]

🚨 Edited by proposal-police: This proposal was edited at 2026-07-09 16:39:32 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

When a user invites a new member from the Workspace Members settings page and clicks on that newly added member's row in the list, the Right Hand Panel (RHP) fails to load their details and instead displays a generic "Hmm... it's not here" (NotFound) error page.

What is the root cause of that problem?

The issue is caused by a race condition between the optimistic UI state cleanup and the component's routing logic.

  1. Optimistic Account ID: When a new member is invited, the app generates an optimistic accountID (via generateAccountID) and creates a temporary personalDetails entry in Onyx for that user.
  2. Premature Click: The optimistic user appears in the UI instantly. Clicking the user routes the RHP to /w/:policyID/members/:optimisticAccountID/details.
  3. Optimistic Cleanup Deletion: When the AddMembersToWorkspace backend API responds successfully, it returns the user's permanent accountID. The finallyData from the API response then executes, which explicitly deletes the optimistic personalDetails entry (e.g., personalDetails[optimisticAccountID] = null) to clean up duplicates.
  4. Crash in Details Page: Because WorkspaceMemberDetailsPage is currently mounted at the optimistic route, the sudden deletion of personalDetails[optimisticAccountID] causes memberLogin to evaluate to ''. This leads to member evaluating to undefined, which trips the shouldShowNotFoundPage condition, resulting in the error view.

What changes do you think we should make in order to solve the problem?

We need to gracefully handle the transition from the optimistic accountID to the real accountID within WorkspaceMemberDetailsPage.tsx.

In src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:

  1. Retain the Member Login: We will introduce a usePrevious hook to memorize the accountLogin. This ensures that even when the optimistic personal details get deleted, the component still knows which memberLogin it is displaying.
const accountLogin = personalDetails?.[accountID]?.login ?? '';
const prevAccountLogin = usePrevious(accountLogin);
const memberLogin = accountLogin || prevAccountLogin || '';
  1. Discover the Real Account ID: Using the memorized memberLogin, we will look up the new, real accountID that the backend just returned by using getPersonalDetailByEmail.
const realAccountID = useMemo(() => {
    if (!memberLogin) {
        return accountID;
    }
    const personalDetail = PersonalDetailsUtils.getPersonalDetailByEmail(memberLogin);
    return personalDetail?.accountID ?? accountID;
}, [memberLogin, accountID]);
  1. Fetch Details & Redirect: We will fetch the details for realAccountID, and use Navigation.setParams to seamlessly correct the URL parameters without breaking the navigation stack. This fixes the immediate crash and ensures that reloading the page or sharing the link uses the correct ID.
// Fetch details using the real accountID so it has avatar and display name
const details = personalDetails?.[realAccountID] ?? ({} as PersonalDetails);

// Update the URL to the real accountID
useEffect(() => {
    if (realAccountID && realAccountID !== accountID) {
        Navigation.setParams({accountID: realAccountID});
    }
}, [realAccountID, accountID]);

What alternative solutions did you explore? (Optional)

  • We explored changing shouldShowNotFoundPage = false while data is loading, but this breaks legitimate NotFound edge cases.
  • We explored altering the route to include the login as a parameter (similar to how ProfilePage works), but this would require refactoring all related routes, parameters, and deeplinks across the codebase, making it highly invasive. The proposed component-level fix seamlessly patches the data layer transition without altering any API contracts or route structures.

ashu75575 avatar Jul 09 '26 16:07 ashu75575

proposal updated

ashu75575 avatar Jul 09 '26 16:07 ashu75575

Updated my proposal.

What changed: Updated the proposal to focus on the optimistic invite accountID cleanup race and the ignored optimistic-row interaction guard.

Why: The video shows the member details panel render first, then flip to not-found on the same route after invite data refresh.

KJ21-ENG avatar Jul 09 '26 16:07 KJ21-ENG

Proposal

What is the root cause of that problem?

Two things have to line up for this to happen, and the first one is a regression.

1. The just-invited row should not be clickable, but it is — the guard that used to block it is now dead code.

When you invite a brand-new email, buildAddMembersToWorkspaceOnyxData writes an optimistic personal detail keyed by a client-generated accountID (generateAccountID(login)), tagged isOptimisticPersonalDetail: true, and registers a cleanup that nulls it once the invite succeeds:

WorkspaceMembersPage still computes the intended guard for that state — isInteractive: !details.isOptimisticPersonalDetail at line 384 — but the flag goes nowhere. The new table row hardcodes interactive and never reads item.isInteractive:

WorkspaceMembersTableRow.tsx#L56-L64

isInteractive isn't even a field on WorkspaceMemberRowData, so it's an excess property on the inferred .map() result and TypeScript never flags it. Table.Row does honor interactive={false} to swallow the press (TableRow.tsx#L155-L158) — the value just never reaches it.

This is a regression from #91746 "Update the workspace members table to the new style" (merged 2026-06-24, so present in 9.4.32). Before it, the page rendered members through SelectionListWithModal, and BaseListItem consumed the same flag — interactive={item.isInteractive} — so an optimistic member was genuinely non-pressable. The migration kept computing isInteractive but dropped the consumer. Note disabled doesn't save us here: it's isPendingDeleteOrError, which is false for an ADD-optimistic member.

2. Once you can click it, the details page can't survive the optimistic→real accountID swap.

The row navigates with that optimistic accountID (WorkspaceMembersPage.tsx#L299-L301). WorkspaceMemberDetailsPage resolves the member with a two-hop lookup keyed off the route param — accountID → personalDetails[accountID].login → employeeList[login]:

WorkspaceMemberDetailsPage.tsx#L97-L101

While the invite is in flight this renders fine. When it succeeds, the cleanup sets personalDetails[optimisticAccountID] = null and the real details arrive under a different real accountID. The RHP's route param is frozen on the now-dead optimistic accountID → memberLogin becomes '' → member = employeeList[''] is undefined → shouldShowNotFoundPage fires:

WorkspaceMemberDetailsPage.tsx#L276-L281

That's the "opens for a moment, then flips to Hmm... it's not here" in the video — the flip is the success response landing. The list itself self-heals (getMemberAccountIDsForWorkspace re-resolves the login to the real accountID once real details arrive), which is why only the already-open RHP is stuck.

What changes do you think we should make in order to solve the problem?

Reconnect the guard that #91746 orphaned — this is a render-layer fix and it's the minimal revert of the regression:

  1. Add isInteractive: boolean to WorkspaceMemberRowData in index.tsx#L25-L41.
  2. In WorkspaceMembersTableRow.tsx#L56-L64, pass interactive={item.isInteractive} instead of the hardcoded interactive.

An optimistic member's row then swallows the press (TableRow.handleRowPress returns early on !interactive) until the invite succeeds and isOptimisticPersonalDetail clears — at which point the row is interactive again and navigates with the real accountID, so the details page resolves normally. No new state, no timing heuristics; it restores the exact pre-migration behavior. Offline: the member stays optimistic (no success response), so the row stays non-interactive, which is the correct pre-#91746 behavior.

I'd keep the details-page hardening (below) out of the primary fix. It's real but it's a different, unreported scenario, and stacking it here would paper over the dead guard rather than fix it.

What alternative solutions did you explore? (Optional)

Harden WorkspaceMemberDetailsPage instead of gating the row — e.g. cache the last-good detail via usePrevious, or re-resolve the real accountID from the login and Navigation.setParams. Rejected as the primary fix: it leaves the isInteractive flag dead, so the row stays wrongly clickable and every other consumer of that intent (the profile branch in openMemberDetails, custom-field/role sub-pages opened from the RHP) keeps carrying the doomed optimistic accountID. It's worth doing as a follow-up to also cover deep-linking/refreshing a stale optimistic-accountID URL, which the row fix alone won't catch — but that path isn't what this bug reports.

Keep the optimistic personal detail alive (drop the cleanup from successData) — rejected: the cleanup at Member.ts#L919-L925 exists specifically to avoid a duplicate personal-details entry once the backend returns the real accountID, and removing it trades this bug for a stale-duplicate bug.

Lowercase the optimistic employeeList keys — rejected as the cause here. The reporter's flow uses a plain lowercase email; the lookup fails because personalDetails[accountID] is nulled, not because of key casing, so memberLogin is '' regardless of case.

oqildev avatar Jul 09 '26 16:07 oqildev

Proposal

Please re-state the problem that we are trying to solve in this issue.

After inviting a brand-new member from Workspace Settings › Members and immediately clicking that just-added row, the member-details RHP renders for a moment and then flips to the "Hmm... it's not here" (NotFound) error instead of the member's details.

What is the root cause of that problem?

The just-invited row should not be clickable while it is still optimistic, but it is — the guard that used to block it was orphaned in the recent members-table migration.

When you invite a brand-new email, the app writes an optimistic personal detail keyed by a client-generated accountID (generateAccountID), tagged isOptimisticPersonalDetail: true, and registers a cleanup that nulls it once the invite succeeds:

WorkspaceMembersPage still computes the intended guard for exactly this state — isInteractive: !details.isOptimisticPersonalDetail — but the flag now goes nowhere. The new table row hardcodes interactive and never reads item.isInteractive:

WorkspaceMembersTableRow.tsx#L57-L60

isInteractive isn't even a field on WorkspaceMemberRowData, so it's just an excess property on the inferred .map() result and TypeScript never flags the drop. Table.Row does honor interactive={false} (it swallows the press in TableRow.tsx#L155-L157 and renders it as non-pressable at #L195-L196) — the value just never reaches it. Note disabled doesn't save us either: it's disabled: isPendingDeleteOrError, which is false for an ADD-optimistic member.

This is a regression from #91746 "Update the workspace members table to the new style" (merged 2026-06-24, so present in 9.4.32-0). Before it, the page rendered members through SelectionListWithModal, whose list item consumed the same flag — interactive={item.isInteractive} — so an optimistic member was genuinely non-pressable. The migration kept computing isInteractive but dropped the consumer.

So the full chain is: the optimistic row is clickable → clicking navigates to WORKSPACE_MEMBER_DETAILS with the optimistic accountID (WorkspaceMembersPage.tsx#L300). WorkspaceMemberDetailsPage resolves the member with a two-hop lookup keyed off that route param — accountID → personalDetails[accountID].login → employeeList[login]:

WorkspaceMemberDetailsPage.tsx#L96-L98

While the invite is in flight this renders fine. When it succeeds, the cleanup sets personalDetails[optimisticAccountID] = null and the real details arrive under a different real accountID. The RHP's route param is frozen on the now-dead optimistic accountID → memberLogin becomes '' → member = employeeList[''] is undefined → shouldShowNotFoundPage fires:

WorkspaceMemberDetailsPage.tsx#L334-L337

That's the "opens for a moment, then flips to Hmm... it's not here" in the video — the flip is the success response landing. The members list itself self-heals (once real details arrive, the login re-resolves to the real accountID), which is why only the already-open RHP is stranded.

What changes do you think we should make in order to solve the problem?

Reconnect the guard that #91746 orphaned. It's the minimal revert of the regression and restores the exact pre-migration behavior:

  1. Add isInteractive: boolean; to WorkspaceMemberRowData at index.tsx#L25-L41 (so the flag is typed and can't be silently dropped again).
  2. In WorkspaceMembersTableRow.tsx#L57-L60, pass interactive={item.isInteractive} instead of the bare hardcoded interactive.

This is safe because it's exactly what BaseListItem already does in production (BaseListItem.tsx#L203). An optimistic member's row swallows the press (TableRow.handleRowPress returns early on !interactive) until the invite succeeds and isOptimisticPersonalDetail clears — at which point the row becomes interactive again and navigates with the real accountID, so the details page resolves normally. No new state, no timing heuristics.

Note (counter-cases preserved): a normal existing member has isOptimisticPersonalDetail === false, so isInteractive is true and the row stays clickable; a member pending delete is already blocked by disabled. Only the ADD-optimistic row changes.

Note (offline): offline there is no success response, so the member stays optimistic and the row stays non-interactive — this is the correct pre-#91746 behavior, and the member has no real accountID to open yet anyway.

This is intentionally minimal: I'd keep the details-page hardening (below) out of the primary fix, since it papers over the dead guard rather than restoring it.

What alternative solutions did you explore? (Optional)

1. Harden WorkspaceMemberDetailsPage instead of gating the row. When the route's accountID stops resolving (optimistic detail just cleaned up), keep the last-good login via the usePrevious pattern already used in this file (#L99), re-resolve the real accountID with getKnownAccountIDByLogin(prevLogin), and Navigation.setParams({accountID}) — hooking into the same lifecycle as the existing "member removed → goBack" effect (#L182-L188). I'd suggest this as a follow-up, not the primary fix: it additionally covers deep-linking/refreshing a stale optimistic-accountID URL, but on its own it leaves the isInteractive guard dead, so the row stays wrongly clickable and every RHP sub-page opened from it (role, custom fields, and the profile branch of openMemberDetails) keeps carrying the doomed optimistic accountID.

2. Keep the optimistic personal detail alive (drop the cleanup from successData). Rejected: the cleanup at Member.ts#L919-L920 exists specifically to avoid a duplicate personal-details entry once the backend returns the real accountID — removing it trades this bug for a stale-duplicate bug.

yusufdeveloper2903 avatar Jul 09 '26 16:07 yusufdeveloper2903

⚠️ @yusufdeveloper2903 Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

github-actions[bot] avatar Jul 09 '26 16:07 github-actions[bot]

Proposal — [#95725] WS settings: inviting a member then clicking it shows an error (NotFoundPage) in the RHP

Problem Statement

In Workspace Settings → Members, after inviting a new member and then clicking that member's row, the right-hand panel (RHP) renders the "not found" / error page instead of the member's details.

Reproduction (all platforms — Web, Desktop, iOS, Android, mWeb):

  1. Open any workspace → Members.
  2. Invite member → add a brand-new user (a login not already known to the account) → confirm.
  3. Click the freshly-added member row while / right as the invite is being confirmed.
  4. The RHP shows the not-found error page.

Root Cause

There are two layers. The list layer lets the user open the RHP with an accountID that is guaranteed to become invalid; the details layer then can't survive that accountID going away. The reported bug is triggered by the list layer.

How optimistic invites work (verified)

When a brand-new user (no existing personal details) is invited, buildAddMembersToWorkspaceOnyxData creates an optimistic personal detail:

  • PersonalDetailsUtils.getNewAccountIDsAndLogins picks logins with no existing personal detail and assigns each a generated optimistic accountID (generateAccountID(login), see PersonalDetailsUtils.ts:285).
  • getPersonalDetailsOnyxDataForOptimisticUsers writes personalDetails[optimisticAccountID] = { login, accountID, …, isOptimisticPersonalDetail: true } as optimisticData, and — critically — puts personalDetails[optimisticAccountID] = null into finallyData (PersonalDetailsUtils.ts:359).
  • That finallyData is folded into the command's successData (Member.ts:919-920). So when the invite resolves, the optimistic personal detail is deleted, and the backend returns the member under a real accountID.

Net effect: the optimistic accountID a row was built with is a throwaway that is nulled on success.

List layer — the trigger (regression)

WorkspaceMembersPage.tsx:384 still computes a guard for exactly this case:

isInteractive: !details.isOptimisticPersonalDetail,

But isInteractive is dead code. The row type WorkspaceMemberRowData is TableData & {…} (WorkspaceMembersTable/index.tsx:25), and TableData only defines keyForList, disabled?, isSelectionDisabled? (Table/types.ts:14-23). isInteractive is not a field on the row, so it is silently discarded (it survives typecheck only because it's an excess property on an inferred .map() result, not a fresh literal assignment).

The row component never reads it either: WorkspaceMembersTableRow.tsx:57-58 hardcodes interactive on Table.Row and only forwards disabled={item.disabled} (line 60).

Consequently the optimistic (just-invited) row stays pressable. Pressing it calls openMemberDetails, which navigates to WORKSPACE_MEMBER_DETAILS.getRoute(policyID, accountID) with the optimistic accountID.

Details layer — where the error surfaces

WorkspaceMemberDetailsPage resolves the member via a two-hop lookup:

const accountID = Number(route.params.accountID);                 // :97  (optimistic id)
const memberLogin = personalDetails?.[accountID]?.login ?? '';    // :98
const member = policy?.employeeList?.[memberLogin];               // :99
…
const shouldShowNotFoundPage = !member || …;                      // :276
if (shouldShowNotFoundPage) return <NotFoundPage />;              // :279

The RHP is opened on the optimistic accountID. When the invite successData nulls personalDetails[optimisticAccountID], hop 1 yields memberLogin = '', hop 2 yields member = undefined, so shouldShowNotFoundPage becomes true and the RHP flips to NotFoundPage. That is the error the tester sees.

The canonical sibling proves the intended fix

The equivalent domain screen handles this correctly and its table is architecturally identical (row hardcodes interactive, forwards disabled={item.disabled} — DomainMembersTableRow.tsx:55-57):

// DomainMembersPage.tsx:129
disabled: isPendingActionDelete || !!details?.isOptimisticPersonalDetail,

DomainMembersPage folds the optimistic flag into disabled (a real, consumed TableData field). WorkspaceMembersPage instead used a phantom isInteractive field and left isOptimisticPersonalDetail out of disabled (WorkspaceMembersPage.tsx:394) — the divergence.

Proposed Solution (recommended)

Mirror the canonical DomainMembersPage implementation: fold isOptimisticPersonalDetail into the row's disabled field and remove the dead isInteractive line.

File: src/pages/workspace/WorkspaceMembersPage.tsx (the data memo, ~lines 365-400)

-                isInteractive: !details.isOptimisticPersonalDetail,
                 isSelectionDisabled:
                     !canWriteMembers ||
                     accountID === policy?.ownerAccountID ||
                     accountID === session?.accountID ||
                     !canMemberManageMemberWithRole(policy, currentUserLogin ?? '', policyEmployee.role),
                 shouldShowEmployeeUserID: shouldShowCustomField1Column,
                 shouldShowEmployeePayrollID: shouldShowCustomField2Column,
                 errors: getLatestErrorMessageField(policyEmployee),
                 pendingAction: policyEmployee.pendingAction,
-                disabled: isPendingDeleteOrError,
+                disabled: isPendingDeleteOrError || !!details.isOptimisticPersonalDetail,

While the invite is optimistic, the row is not pressable (and shows the standard offline/pending affordance via the existing OfflineWithFeedback on pendingAction: 'add'). Once the invite succeeds, the optimistic detail is replaced by the real one, isOptimisticPersonalDetail is gone, the row re-enables, and navigation now uses the real accountID — both lookup hops resolve and the RHP shows details. The failure window is closed at the source.

Why this is the right fix

  • Matches canonical architecture. Identical to DomainMembersPage.tsx:129, which is the working reference for the same table framework and same optimistic-invite mechanic. No new pattern introduced.
  • No duplication. Reuses the existing disabled field, the existing isOptimisticPersonalDetail flag, and the existing Table.Row disabled handling (TableRow.tsx:129,156 block both press and long-press). Removes dead code rather than adding logic.
  • Minimal blast radius. One line changed, one dead line removed, in one file. No changes to actions, Onyx shapes, navigation, or the details page.

Alternative Solutions (inferior)

  1. Harden the details page with a reverse lookup / fallback resolution. In WorkspaceMemberDetailsPage, when personalDetails[accountID] is missing, fall back to resolving the member some other way (e.g. reverse-scan employeeList, or cache the last-known login with usePrevious). Inferior: treats the symptom, not the trigger — the RHP would still have opened on a doomed optimistic accountID. It adds resolution logic that doesn't exist in the canonical DomainMemberDetails path, increasing surface area and drift between the two nearly-identical member-details screens. A usePrevious/cache approach also risks showing a stale member after the id genuinely changes.

  2. Re-resolve the real accountID and Navigation.setParams when the optimistic detail is cleaned up. Detect the optimistic→real swap and rewrite the route param in place. Inferior: most complex option; introduces an effect that mutates navigation state mid-flight (ordering/race hazards across platforms), and again is unique to this screen. High regression risk for a problem the one-line list guard eliminates.

  3. Re-introduce a real isInteractive prop end-to-end (add to TableData/WorkspaceMemberRowData and thread interactive={item.isInteractive} into Table.Row). Inferior: changes the shared Table contract and every table's row API for a case the existing disabled field already covers. DomainMembersPage demonstrates disabled is the intended mechanism; adding a parallel interactive field is redundant surface and a wider-reaching change.

Testing

Manual / regression (matches issue repro):

  • Invite a brand-new user, click the row before the invite confirms → row is not pressable; no RHP error. After confirmation → row is pressable, RHP shows correct details.
  • Invite an existing Expensify user (already in personal details, no optimistic id) → row remains immediately pressable, RHP opens correctly.
  • Offline invite → row shows pending "add" style and is not pressable; after reconnect+confirm it becomes pressable.
  • Existing members, owner row, current-user row, pending-delete rows, error rows → interactivity unchanged.
  • Bulk selection / role changes on normal members → unchanged (optimistic rows were never valid selection targets; isSelectionDisabled already excluded owner/self/non-manageable).

Automated:

  • tests/ — there are no dedicated WorkspaceMembersPage render tests today; the natural home for coverage is a unit test around the data memo mapping, asserting disabled === true when details.isOptimisticPersonalDetail is truthy and false otherwise (mirroring any coverage added for DomainMembersPage). Confirm with the assigned engineer whether Expensify wants a new test file (tests/unit/WorkspaceMembersPageTest.ts) or an extension of an existing members-flow test before adding.

Risks

Risk Likelihood Mitigation
Legitimately-clickable rows become disabled Very low isOptimisticPersonalDetail is only set for brand-new invited users with no real personal detail; it's cleared on success. Existing/real members are unaffected. Behavior matches DomainMembersPage.
Optimistic row also blocks selection checkbox / bulk actions Very low / intended disabled blocks press, long-press and selection in TableRow; an in-flight, not-yet-created member should not be a bulk-action target. Same as domain members.
Offline mode: member stays disabled Expected Optimistic add is inherently unconfirmed offline; the pending affordance communicates state. Re-enables on reconnect + success.
Cross-platform (web/desktop/iOS/android) divergence None Change is platform-agnostic JS in the shared page; Table.Row disabled handling is shared.

Why this approach

It fixes the bug at the exact layer where the defect was introduced (a dead guard on the list), restores parity with the already-correct canonical sibling (DomainMembersPage), reuses existing fields and framework behavior instead of adding new logic, removes dead code, and keeps the change to a single line in a single file — the smallest change a long-term maintainer would accept, with the least regression surface.

intel0725 avatar Jul 09 '26 16:07 intel0725

@daledah I am not able to reproduce this issue.

https://github.com/user-attachments/assets/1c8945ef-f796-4fd7-8d8d-21808a64f18e

emkhalid avatar Jul 09 '26 16:07 emkhalid

Proposal

What is the root cause of that problem?

There are two related problems.

1. Optimistic member rows are clickable after the table migration

After migrating the workspace members list to Table, every row is hardcoded as pressable:

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/components/Tables/WorkspaceMembersTable/WorkspaceMembersTableRow.tsx#L57-L64

WorkspaceMembersPage already marks newly invited members as non-interactive while their personal details are still optimistic:

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/pages/workspace/WorkspaceMembersPage.tsx#L384

That flag is passed in the row .map() but the migrated row component ignores it and always sets interactive, so tapping an invited member still opens member details:

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/pages/workspace/WorkspaceMembersPage.tsx#L397

2. Member details is keyed by a fragile optimistic accountID

Navigation and deeplinks use accountID in the route:

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/ROUTES.ts#L2690-L2692

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/pages/workspace/WorkspaceMembersPage.tsx#L300

WorkspaceMemberDetailsPage resolves the member through that route accountID → personalDetails[accountID].login → employeeList[login]:

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L97-L99

For a brand-new invitee, the route carries a client-generated optimistic accountID. When the invite succeeds, that optimistic personal detail is cleaned up and the real member exists under a different accountID, while employeeList remains keyed by the stable login/email. The route param no longer resolves → member is undefined → NotFoundPage:

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L276-L280

This also affects deeplinks that open /workspaces/:policyID/members/:accountID with a stale or optimistic ID.

What changes do you think we should make in order to solve the problem?

Apply a two-part fix: prevent opening optimistic rows, and make member details resolve from the stable workspace member key (email/login).

1. Restore the optimistic-row guard in the members table

Add isInteractive to WorkspaceMemberRowData and pass it through to Table.Row:

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/components/Tables/WorkspaceMembersTable/index.tsx#L25-L41

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/components/Tables/WorkspaceMembersTable/WorkspaceMembersTableRow.tsx#L57-L64

type WorkspaceMemberRowData = TableData & {
    ...
    isInteractive: boolean;
}

<Table.Row
    interactive={item.isInteractive}
    onPress={item.action}
>

WorkspaceMembersPage already sets isInteractive: !details.isOptimisticPersonalDetail — no change needed there.

2. Key member details by email/login instead of accountID

Use the same stable key as policy.employeeList (login/email), not the throwaway optimistic accountID.

Route + types

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/ROUTES.ts#L2690-L2692

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/libs/Navigation/types.ts#L656-L659

WORKSPACE_MEMBER_DETAILS:
    route: 'workspaces/:policyID/members/:login'
    getRoute: (policyID, login) => `workspaces/${policyID}/members/${encodeURIComponent(login)}`

SettingsNavigatorParamList[MEMBER_DETAILS]:
    { policyID: string; login: string }

Update linking config to match. Child routes that navigate back to member details (MEMBER_DETAILS_ROLE, WORKSPACE_CUSTOM_FIELDS, owner-change flows) should use the same login param when building getRoute.

Navigation from the members list

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/pages/workspace/WorkspaceMembersPage.tsx#L292-L301

openMemberDetails(login: string):
    Navigation.navigate(ROUTES.WORKSPACE_MEMBER_DETAILS.getRoute(policyID, login))

action: () => openMemberDetails(login)

Member details resolution

https://github.com/Expensify/App/blob/86ac9faf6edc5e0e50bdcde59a02c0e525323c7f/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L97-L101

memberLogin = decodeURIComponent(route.params.login)
member = policy?.employeeList?.[memberLogin]
accountID = getPersonalDetailByEmail(memberLogin)?.accountID
            ?? getMemberAccountIDsForWorkspace(policy?.employeeList)[memberLogin]
details = personalDetails?.[accountID] ?? ({} as PersonalDetails)

member comes from employeeList (stable across optimistic → real accountID swap). accountID is derived from personal details when available, so existing profile/card logic that needs an account ID still works. Deeplinks and in-app navigation both land on the same login-based route, so the page no longer depends on a specific optimistic accountID surviving in Onyx.

What alternative solutions did you explore? (Optional)

nkdengineer avatar Jul 09 '26 18:07 nkdengineer

Proposal

Please re-state the problem that we are trying to solve in this issue.

When an admin invites a brand-new member (someone with no existing Expensify account) from Workspace Settings > Members, and then immediately taps on that newly-added member's row, the Right-Hand Panel shows an error ("Hmm... it's not here") instead of the member's profile.

What is the root cause of that problem?

When a login has no existing personal details, buildAddMembersToWorkspaceOnyxData generates a client-side "optimistic" accountID for it (via PersonalDetailsUtils.getNewAccountIDsAndLogins/UserUtils.generateAccountID, which just hashes the search string) and stores a temporary PersonalDetailsList entry under that ID.

https://github.com/Expensify/App/blob/65a29b386da45e27b75afd624415f29aff457640/src/libs/PersonalDetailsUtils.ts#L337-L382

personalDetailsCleanup[accountID] = null is returned as finallyData, and that finallyData is spread only into successData (not failureData), so as soon as ADD_MEMBERS_TO_WORKSPACE succeeds the temporary personal detail for that hashed accountID is deleted from Onyx, on the assumption that the backend will have already replaced it with a personal detail keyed by the real accountID.

https://github.com/Expensify/App/blob/65a29b386da45e27b75afd624415f29aff457640/src/libs/actions/Policy/Member.ts#L902-L925

For a genuinely new user, that replacement either never arrives with the same key or arrives after this cleanup runs, since the request typically resolves before the tester re-opens the Members list and taps the row. The member row's onPress bakes the (now-stale) accountID into the navigation route:

Navigation.navigate(ROUTES.WORKSPACE_MEMBER_DETAILS.getRoute(route.params.policyID, accountID)) in src/pages/workspace/WorkspaceMembersPage.tsx (openMemberDetails, around line 300).

Once WorkspaceMemberDetailsPage mounts with that stale accountID, it derives the member purely from personalDetails[accountID], which is now undefined/null, so memberLogin becomes an empty string and the policy.employeeList lookup fails:

https://github.com/Expensify/App/blob/65a29b386da45e27b75afd624415f29aff457640/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L97-L101

Because member is falsy, shouldShowNotFoundPage evaluates to true and the page renders NotFoundPage in the RHP:

https://github.com/Expensify/App/blob/65a29b386da45e27b75afd624415f29aff457640/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L276-L281

What changes do you think we should make in order to solve the problem?

Cache the last known-good personal detail for the accountID so that the member lookup survives the moment the optimistic personal detail record is cleaned up in Onyx (mirroring the existing usePrevious(member) pattern already used lower in the same file for the delete flow):

https://github.com/Expensify/App/blob/65a29b386da45e27b75afd624415f29aff457640/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L97-L101

const accountID = Number(route.params.accountID);
const currentPersonalDetails = personalDetails?.[accountID];
const prevPersonalDetails = usePrevious(currentPersonalDetails);
const resolvedPersonalDetails = currentPersonalDetails ?? prevPersonalDetails;
const memberLogin = resolvedPersonalDetails?.login ?? '';
const member = policy?.employeeList?.[memberLogin];
const prevMember = usePrevious(member);
const details = resolvedPersonalDetails ?? ({} as PersonalDetails);

This keeps memberLogin (and therefore the policy.employeeList lookup) pointed at the correct member even for the render(s) where personalDetails[accountID] has been nulled out by the optimistic-data cleanup, so member stays defined and shouldShowNotFoundPage no longer trips, letting the RHP render the member's profile instead of the not-found error.

abbasifaizan70 avatar Jul 09 '26 20:07 abbasifaizan70

🚨 Edited by proposal-police: This proposal was edited at 2026-07-10 02:20:37 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

After inviting a member from Workspace settings > Members, clicking on that newly added member opens the Right Hand Panel with a "Hmm... it's not here" error instead of the member details page.

What is the root cause of that problem?

The invited member is temporarily listed under an optimistic accountID, and the member details page keeps using that accountID after it has been thrown away.

When an admin invites someone who does not have an account yet, the invite option is built with an optimistic accountID derived from the login:

https://github.com/Expensify/App/blob/7e966b4a322864cf3addd3b4eff0f8ef55a84454/src/libs/OptionsListUtils/index.ts#L2059-L2060

That accountID is just a hash of the login:

https://github.com/Expensify/App/blob/7e966b4a322864cf3addd3b4eff0f8ef55a84454/src/libs/UserUtils.ts#L216-L218

The invite writes an optimistic personal-details entry under that hashed accountID, and — in the same helper — queues a cleanup that removes it once the request finishes, because the backend returns the member's real accountID:

https://github.com/Expensify/App/blob/7e966b4a322864cf3addd3b4eff0f8ef55a84454/src/libs/PersonalDetailsUtils.ts#L355-L359

The members list turns each employeeList key into an accountID by looking the login up in personal details:

https://github.com/Expensify/App/blob/7e966b4a322864cf3addd3b4eff0f8ef55a84454/src/libs/PolicyUtils.ts#L798-L801

While the invite is still in flight, the only personal-details entry for that login is the optimistic one, so the row points at /members/<optimisticAccountID>.

The member details page takes that accountID straight from the route and derives everything else from it:

https://github.com/Expensify/App/blob/7e966b4a322864cf3addd3b4eff0f8ef55a84454/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L97-L99

When the invite request completes, the optimistic personal-details entry is nulled and a new entry appears under the real accountID. The details page is still holding the optimistic accountID, so personalDetails[accountID] is now undefined, memberLogin collapses to '', policy.employeeList[''] is undefined, and the page renders the not-found error:

https://github.com/Expensify/App/blob/7e966b4a322864cf3addd3b4eff0f8ef55a84454/src/pages/workspace/members/WorkspaceMemberDetailsPage.tsx#L276-L277

The video in the report confirms this exactly. The failing URL is .../members/1578573896, and generateAccountID("[email protected]") — the member that was just invited and clicked — evaluates to precisely 1578573896. The member is still present in the list behind the panel; only the accountID in the route has gone stale.

This also explains why the bug looks intermittent: if you wait for the invite to finish before clicking the row, the list already resolves the member's real accountID and the details page opens normally. The error only appears when the details page is opened while the invite is still in flight, which is the natural thing to do right after clicking Invite.

What changes do you think we should make in order to solve the problem?

Make the member details page survive the optimistic-to-real accountID swap, in WorkspaceMemberDetailsPage.

  1. When personalDetails[<accountID from the route>] is missing, recover the member's login from the workspace's own employeeList: find the key whose optimistic accountID — the same login hash the invite used, also allowing for the SMS domain that phone logins carry — equals the accountID in the route. This is the only piece of information the stale route still encodes, and employeeList is keyed by exactly the login that produced it, so the member is recoverable without any new data.

  2. Resolve that login back to the member's current personal details, and use the real accountID from those details for the rest of the page rather than the stale route value. Everything downstream — the role and remove controls, removeMembers, the card lookups, the "is this me" check — then operates on the member's real accountID instead of a hash that no longer exists.

With those two steps, member resolves again, shouldShowNotFoundPage stops firing, and the panel keeps showing the member's details as the invite settles. Nothing changes for a member whose route accountID is already real: the existing personal-details lookup hits on the first try and the fallback never runs. A member who genuinely is not in the workspace still resolves to no login and still gets the not-found page.

Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/95725-member-details-case-insensitive-lookup?expand=1

What alternative solutions did you explore? (Optional)

Redirecting the route to the real accountID (via Navigation.setParams) as soon as it appears. This also fixes the panel, but it introduces a navigation side effect while the page is rendering, and it leaves the page broken for anyone who deep-links or refreshes on the optimistic accountID before the redirect runs. Resolving the member is the smaller, more predictable change.

Preventing the members list from linking a row while its member still has a pending ADD action. This does not actually fix the reported case: the pending state has already cleared by the time the error appears, and it would block a legitimate interaction for offline invites.

Treating this as an email-casing mismatch between the employeeList key and the canonical login, and resolving the employee case-insensitively. I explored this first, but it is not the cause: the invite page lowercases the search value before the option is built, and the account-ID hash lowercases its input as well, so inviting [email protected] and [email protected] produce identical keys and identical behaviour. I confirmed on main that a mixed-case invite opens the details page without error once the request settles, so casing cannot be what breaks it.

wildan-m avatar Jul 09 '26 23:07 wildan-m