Skip to content

[Due for payment 2026-07-29] [$250] WS settings - Invite member from WS settings then clicking on it gives error in RHP #95725

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com 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): emady.syed1234+newuser123@gmail.com
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
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7203901_1783611252362.Recording__977.mp4

View all open jobs on GitHub

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

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 9, 2026
  2. applause-bot commented on Jul 9, 2026

    @applause-bot
    Author

    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

  3. MelvinBot commented on Jul 9, 2026

    @MelvinBot
    Contributor

    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.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 9, 2026
  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 9, 2026
  6. David-2002065 commented on Jul 9, 2026

    @David-2002065
    Contributor

    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:

    /**
    * Cleanup the optimistic user to ensure it does not permanently persist.
    * This is done to prevent duplicate entries (upon success) since the BE will return other personal details with the correct account IDs.
    */
    personalDetailsCleanup[accountID] = null;
    }

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

    successData.push(
    ...(newPersonalDetailsOnyxData.finallyData ?? []),
    ...membersChats.onyxSuccessData,
    ...announceRoomChat.onyxSuccessData,
    ...(announceRoomMembers.successData ?? []),
    ...(adminRoomMembers.successData ?? []),
    );

    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:

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

    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:

    const shouldShowNotFoundPage =
    !member || (member.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && prevMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
    if (shouldShowNotFoundPage) {
    return <NotFoundPage />;
    }

    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.
  7. aswin-s commented on Jul 9, 2026

    @aswin-s
    Contributor

    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)

  8. trasnake87 commented on Jul 9, 2026

    @trasnake87
    Contributor

    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.

  9. samranahm commented on Jul 9, 2026

    @samranahm
    Contributor

    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:

    function formatPhoneNumber(number: string): string {
    if (!number) {
    return '';
    }
    // eslint-disable-next-line no-param-reassign
    number = number.replaceAll(' ', '\u00A0');
    // do not parse the string, if it doesn't contain the SMS domain and it's not a phone number
    if (number.indexOf(CONST.SMS.DOMAIN) === -1 && !CONST.REGEX.DIGITS_AND_PLUS.test(number)) {
    return number;
    }
    const numberWithoutSMSDomain = Str.removeSMSDomain(number);
    const parsedPhoneNumber = parsePhoneNumber(numberWithoutSMSDomain);
    // return the string untouched if it's not a phone number
    if (!parsedPhoneNumber.valid) {
    if (parsedPhoneNumber.number?.international) {
    return parsedPhoneNumber.number.international;
    }
    return numberWithoutSMSDomain;
    }
    const regionCode = parsedPhoneNumber.countryCode;
    if (regionCode === countryCodeByIPOnyx) {
    return parsedPhoneNumber.number.national;
    }
    return parsedPhoneNumber.number.international;
    }

    function parsePhoneNumber(phoneNumber: string, options?: PhoneNumberParseOptions): ParsedPhoneNumber {
    const parsedPhoneNumber = originalParsePhoneNumber(phoneNumber, options);
    if (!parsedPhoneNumber.possible) {
    return parsedPhoneNumber;
    }
    const phoneNumberWithoutSpecialChars = phoneNumber.replaceAll(CONST.REGEX.SPECIAL_CHARS_WITHOUT_NEWLINE, '');
    if (!CONST.REGEX.PHONE_NUMBER.test(phoneNumberWithoutSpecialChars)) {
    return {
    ...parsedPhoneNumber,
    valid: false,
    possible: false,
    number: {
    ...parsedPhoneNumber.number,
    e164: phoneNumberWithoutSpecialChars,
    international: phoneNumberWithoutSpecialChars,
    national: phoneNumberWithoutSpecialChars,
    rfc3966: `tel:${phoneNumberWithoutSpecialChars}`,
    significant: phoneNumberWithoutSpecialChars,
    },
    } as ParsedPhoneNumberInvalid;
    }
    if (!/^\+11[0-9]{10}$/.test(phoneNumberWithoutSpecialChars)) {
    return parsedPhoneNumber;
    }
    const countryCode = phoneNumberWithoutSpecialChars.substring(0, 2);
    const phoneNumberWithoutCountryCode = phoneNumberWithoutSpecialChars.substring(2);
    return {
    ...parsedPhoneNumber,
    valid: false,
    possible: false,
    number: {
    ...parsedPhoneNumber.number,
    // mimic the behavior of awesome-phonenumber
    e164: phoneNumberWithoutSpecialChars,
    international: `${countryCode} ${phoneNumberWithoutCountryCode}`,
    national: phoneNumberWithoutCountryCode,
    rfc3966: `tel:${countryCode}-${phoneNumberWithoutCountryCode}`,
    significant: phoneNumberWithoutCountryCode,
    },
    } as ParsedPhoneNumberInvalid;
    }

    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:

    function formatPhoneNumber(number: string): string {
    if (!number) {
    return '';
    }
    // eslint-disable-next-line no-param-reassign
    number = number.replaceAll(' ', '\u00A0');
    // do not parse the string, if it doesn't contain the SMS domain and it's not a phone number
    if (number.indexOf(CONST.SMS.DOMAIN) === -1 && !CONST.REGEX.DIGITS_AND_PLUS.test(number)) {
    return number;
    }
    const numberWithoutSMSDomain = Str.removeSMSDomain(number);
    const parsedPhoneNumber = parsePhoneNumber(numberWithoutSMSDomain);
    // return the string untouched if it's not a phone number
    if (!parsedPhoneNumber.valid) {
    if (parsedPhoneNumber.number?.international) {
    return parsedPhoneNumber.number.international;
    }
    return numberWithoutSMSDomain;
    }
    const regionCode = parsedPhoneNumber.countryCode;
    if (regionCode === countryCodeByIPOnyx) {
    return parsedPhoneNumber.number.national;
    }
    return parsedPhoneNumber.number.international;
    }

    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.

  10. KJ21-ENG commented on Jul 9, 2026

    @KJ21-ENG
    Contributor

    🚨 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.

    const inviteLogin = isValidPhoneNumber && parsedPhoneNumber.number?.e164 ? parsedPhoneNumber.number.e164 : searchValue.toLowerCase();
    // Generates an optimistic account ID for new users not yet saved in Onyx
    const optimisticAccountID = generateAccountID(inviteLogin);
    return createOption(
    {
    accountID: optimisticAccountID,
    login: inviteLogin,
    isOptimisticPersonalDetail: true,

    const invitedEmailsToAccountIDs: InvitedEmailsToAccountIDs = {};
    for (const option of selectedOptions) {
    const login = option.login ?? '';
    const accountID = option.accountID ?? CONST.DEFAULT_NUMBER_ID;
    if (!login.toLowerCase().trim() || !accountID) {
    continue;
    }
    invitedEmailsToAccountIDs[login] = Number(accountID);
    }
    setWorkspaceInviteMembersDraft(route.params.policyID, invitedEmailsToAccountIDs);

    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.

    const {newAccountIDs, newLogins} = PersonalDetailsUtils.getNewAccountIDsAndLogins(logins, accountIDs, personalDetailsList);
    const newPersonalDetailsOnyxData = PersonalDetailsUtils.getPersonalDetailsOnyxDataForOptimisticUsers(newLogins, newAccountIDs, formatPhoneNumber);

    for (const email of logins) {
    optimisticMembersState[email] = {
    email,
    pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
    role: effectiveRole,
    submitsTo: approverEmail ?? getDefaultApprover(policy),
    };
    successMembersState[email] = {pendingAction: null};
    failureMembersState[email] = {
    pendingAction: null,
    errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('workspace.people.error.genericAdd'),
    };
    }
    const optimisticData: Array<
    OnyxUpdate<
    | typeof ONYXKEYS.COLLECTION.POLICY
    | typeof ONYXKEYS.PERSONAL_DETAILS_LIST
    | typeof ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS
    | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS
    | typeof ONYXKEYS.COLLECTION.REPORT_METADATA
    | typeof ONYXKEYS.COLLECTION.REPORT
    | typeof ONYXKEYS.COLLECTION.REPORT_DRAFT
    >
    > = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: policyKey,
    // Convert to object with each key containing {pendingAction: 'add'}
    value: {
    employeeList: optimisticMembersState,
    },
    },
    ];
    optimisticData.push(
    ...(newPersonalDetailsOnyxData.optimisticData ?? []),
    ...membersChats.onyxOptimisticData,
    ...announceRoomChat.onyxOptimisticData,
    ...(announceRoomMembers.optimisticData ?? []),
    ...(adminRoomMembers.optimisticData ?? []),
    );
    const successData: Array<
    OnyxUpdate<
    | typeof ONYXKEYS.COLLECTION.POLICY
    | typeof ONYXKEYS.PERSONAL_DETAILS_LIST
    | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS
    | typeof ONYXKEYS.COLLECTION.REPORT_METADATA
    | typeof ONYXKEYS.COLLECTION.REPORT
    >
    > = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: policyKey,
    value: {
    employeeList: successMembersState,
    },
    },
    ];
    successData.push(
    ...(newPersonalDetailsOnyxData.finallyData ?? []),

    personalDetailsNew[accountID] = {
    login,
    accountID,
    avatar: getDefaultAvatarURL({accountID, accountEmail: login}),
    displayName: formatPhoneNumber(login),
    isOptimisticPersonalDetail: true,
    };
    /**
    * Cleanup the optimistic user to ensure it does not permanently persist.
    * This is done to prevent duplicate entries (upon success) since the BE will return other personal details with the correct account IDs.
    */
    personalDetailsCleanup[accountID] = null;
    }
    const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.PERSONAL_DETAILS_LIST>> = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    value: personalDetailsNew,
    },
    ];
    const finallyData: Array<OnyxUpdate<typeof ONYXKEYS.PERSONAL_DETAILS_LIST>> = [
    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.PERSONAL_DETAILS_LIST,
    value: personalDetailsCleanup,
    },

    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.

    const login = details.login ?? '';
    const memberEmail = formatPhoneNumber(login);
    const memberName = formatPhoneNumber(temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate}));
    return {
    keyForList: login,
    role,
    login,
    accountID,
    name: memberName,
    email: memberEmail,
    employeeUserID: policyEmployee.employeeUserID,
    employeePayrollID: policyEmployee.employeePayrollID,
    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,
    // Note which secondary login was used to invite this primary login
    invitedSecondaryLogin: details?.login ? (invitedPrimaryToSecondaryLogins[details.login] ?? '') : '',
    action: () => openMemberDetails(accountID),

    return (
    <Table.Row
    interactive
    rowIndex={rowIndex}
    disabled={item.disabled}
    accessibilityLabel={accessibilityLabel}
    sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.MEMBERS.LIST_ROW}
    offlineWithFeedback={{errors: item.errors, pendingAction: item.pendingAction, onClose: item.dismissError}}
    onPress={item.action}

    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.

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

    const shouldShowNotFoundPage =
    !member || (member.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && prevMember?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
    if (shouldShowNotFoundPage) {
    return <NotFoundPage />;

    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.

    type WorkspaceMemberRowData = TableData & {
    accountID: number;
    login: string;
    role?: string;
    employeeUserID?: string;
    employeePayrollID?: string;
    name: string;
    email: string;
    shouldShowEmployeeUserID: boolean;
    shouldShowEmployeePayrollID: boolean;
    shouldAnimateInHighlight?: boolean;
    errors?: OnyxCommon.Errors;
    pendingAction?: OnyxCommon.PendingAction;
    invitedSecondaryLogin: string;
    action: () => void;
    dismissError: () => void;
    };

    const handleRowPress = (event?: GestureResponderEvent | KeyboardEvent | undefined) => {
    if (isDisabled || !interactive) {
    return;
    }
    if (!selectionUsesNarrowLayout || !isMobileSelectionEnabled || !selectionEnabled) {

    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.

    function getPersonalDetailByEmail(email: string | undefined): PersonalDetails | undefined {
    if (!email) {
    return undefined;
    }
    return emailToPersonalDetailsCache[email.toLowerCase()];
    }
    /**
    * Returns the accountID for a login only when it exists in personal details.
    * Unlike getAccountIDsByLogins, does not fabricate optimistic account IDs for unknown logins.
    */
    function getKnownAccountIDByLogin(login: string | undefined): number | undefined {
    const accountID = getPersonalDetailByEmail(login)?.accountID;
    return accountID !== undefined ? Number(accountID) : undefined;

    const accountID = Number(route.params.accountID);
    const memberLogin = personalDetails?.[accountID]?.login ?? '';
    const member = policy?.employeeList?.[memberLogin];
    const prevMember = usePrevious(member);
    const details = personalDetails?.[accountID] ?? ({} as PersonalDetails);
    const fallbackIcon = details.fallbackIcon ?? '';
    const displayName = formatPhoneNumber(temporaryGetDisplayNameOrDefault({passedPersonalDetails: details, translate}));
    const isSelectedMemberOwner = policy?.owner === details.login;
    const isSelectedMemberCurrentUser = accountID === currentUserAccountID;
    const isCurrentUserAdmin = policy?.employeeList?.[currentUserLogin]?.role === CONST.POLICY.ROLE.ADMIN;
    const isCurrentUserOwner = policy?.owner === currentUserLogin;
    const canWriteMembers = canMemberWrite(policy, currentUserLogin, CONST.POLICY.POLICY_FEATURE.MEMBERS);
    const canManageSelectedMemberRole = canMemberAssignRole(policy, currentUserLogin, member?.role);
    const canRemoveSelectedMember = canWriteMembers && !isSelectedMemberOwner && !isSelectedMemberCurrentUser && canMemberManageMemberWithRole(policy, currentUserLogin, member?.role);
    const ownerDetails = personalDetails?.[policy?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID] ?? ({} as PersonalDetails);
    const policyOwnerDisplayName = formatPhoneNumber(temporaryGetDisplayNameOrDefault({passedPersonalDetails: ownerDetails, translate})) ?? policy?.owner ?? '';
    const {cardList: assignableCards, ...workspaceCards} = getAllCardsForWorkspace(workspaceAccountID, cardList, cardFeeds, expensifyCardSettings);
    const workspaceWorkflowsPageURL = `${environmentURL}/${ROUTES.WORKSPACE_WORKFLOWS.getRoute(policyID)}`;
    const isSMSLogin = Str.isSMSLogin(memberLogin);
    const phoneNumber = getPhoneNumber(details);
    const isReimburser =
    (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES || policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) &&
    policy?.achAccount?.reimburser === memberLogin;
    const {isAccountLocked} = useLockedAccountState();
    const {showLockedAccountModal} = useLockedAccountActions();
    const {approvalWorkflows} = convertPolicyEmployeesToApprovalWorkflows({
    policy,
    personalDetails: personalDetails ?? {},
    localeCompare,
    currentUserLogin,
    });
    useEffect(() => {
    openPolicyMemberProfilePage(policyID, accountID);
    }, [policyID, accountID]);

    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.

  11. melvin-bot commented on Jul 9, 2026

    @melvin-bot

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

  12. melvin-bot commented on Jul 9, 2026

    @melvin-bot
  13. 35 remaining items

  14. melvin-bot commented on Jul 22, 2026

    @melvin-bot

    @daledah The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]

  15. daledah commented on Jul 23, 2026

    @daledah
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to the comment on the PR: N/A

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion:

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/666569

    Regression Test Proposal

    Test:

    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
    6. Verify that: Right hand panel should not show error message.

    Actual

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-ec73-ae4d-61f1-e6dbf1b8c104
  16. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jul 23, 2026
  17. melvin-bot commented on Jul 28, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  18. melvin-bot commented on Jul 28, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    • ROLE: @wildan-m paid $(AMOUNT) via Upwork (LINK)
    • Reviewer: @daledah owed $250 via NewDot

    BugZero Checklist (@mallenexpensify)

    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2075255901660443019/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  19. mallenexpensify commented on Jul 30, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @wildan-m paid $250 via Upwork
    Contributor+: @daledah due $250 via NewDot

    ^ Test case created. Thx

  20. quinthar commented on Aug 19, 2026

    @quinthar
    Contributor

    Approved $250 to @daledah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions