Skip to content

[Due for payment 2026-10-12] [Exploratory] Profile - Invite the secondary contact appear as grey member in Workspace #99823

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.64-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: https://test-management.browserstack.com/projects/2219752/test-runs/71389240/folder/52723565/41236653/1707529874?sort=%2Bidentifier
Email or phone of affected tester (no customers): leungbratt6+29087@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Windows 10/Chrome
App Component: Workspace Settings

Action Performed:

Preconditions: User A has set up a secondary contact in the account

  1. Open the New Dot app as another Admin user of a Workspace
  2. Navigate to the Members page
  3. Invite the secondary contact of User A to the Workspace
  4. Click on the secondary contact grey member

Expected Result:

Only the Main account user A was added to the Workspace

Actual Result:

A main account and the secondary contact appear as a grey member

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome Safari

Screenshots/Videos

Bug7245831_1787990160831.second.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Julia Ponikarchuk
Bug ID: 7245831

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. applause-bot commented on Aug 29, 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/366fde2994023ae8924fa6f65e6b9b664b2620dfe18f56af47a596a5f8b5070d

  2. added
    Bug
    on Sep 5, 2026
  3. MelvinBot commented on Sep 5, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The invite flow is keyed by the email string you typed, never by account. When you invite someone's secondary contact, the client optimistically adds employeeList["secondary@x.com"], the backend resolves it to the primary account and returns employeeList["primary@x.com"], and nothing ever deletes the secondary key. The members page renders one row per employeeList key, so you get two rows for one person.

    Three steps:

    1. Optimistic entry is keyed by the typed secondary email. src/libs/actions/Policy/Member.ts:841 turns the invite draft into a list of raw login strings, and Member.ts:883-895 writes employeeList[<typed email>] with pendingAction: ADD. successData only sets pendingAction: null — it never removes the key. Both the optimistic write and the server response are Onyx.METHOD.MERGE, so the two keys coexist.

    2. This is already a known state, just never cleaned up. The App documents it in Member.ts:388-392: "the backend always returns the primary login, so we end up with both stored in Onyx." The server returns policy.primaryLoginsInvited (secondary → primary) so the client can reconcile — but that map is only used at removal time and for a caption, never to suppress the duplicate row.

    3. The members list renders every key with no de-dupe. WorkspaceMembersPage.tsx:334-369 iterates Object.entries(policy.employeeList). The orphan secondary key has no personal details (the optimistic ones are nulled in finallyData, PersonalDetailsUtils.ts:362-367), so it falls through to the fallback identity at WorkspaceMembersPage.tsx:347-357 — raw email as display name, default avatar. That is the "grey member".

    The page already computes the exact map it needs at WorkspaceMembersPage.tsx:331 — it just doesn't filter with it.

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

    1. Stop rendering the orphan row (the visible bug). In filteredMembers (WorkspaceMembersPage.tsx:333-369), skip any email that is a key of policy.primaryLoginsInvited whose mapped primary login is also present in employeeList. The primary row already shows the "invited by secondary login" caption (:410), so no information is lost. Frontend-only, no backend change.

    2. Clean the stale key out of Onyx (the underlying cause). In buildAddMembersToWorkspaceOnyxData, make successData null the optimistically-added login keys instead of just clearing pendingAction — successMembersState[email] = null at Member.ts:889, the same pattern removeMembers already uses — and let the server's returned employeeList be the source of truth. Confirm first that SaveResponseInOnyx applies successData before the response onyxData; if not, the normal (primary-login) invite would flicker or lose its row.

    3. Exclude known secondary logins from the invite picker. getIneligibleInvitees builds its exclusion list purely from Object.keys(employeeList), so a secondary login of someone who is already a member is still invitable. Fold in the keys of primaryLoginsInvited.

    Items 1 and 3 fix the reported symptom on their own. Item 2 is the real fix and should be verified carefully.

    What alternative solutions did you explore? (Optional)

    Alternatives considered and rejected
    • Resolve secondary → primary before sending the invite. Not possible client-side: PersonalDetails holds a single login per account (types/onyx/PersonalDetails.ts) and loginList covers only the current user's contact methods. The app has no way to know an arbitrary email is someone else's secondary login. Only the backend can map it, which is what primaryLoginsInvited exists for.
    • Have the backend return employeeList: {<secondary>: null}. Correct in principle, but it requires a Web-Expensify change and would leave every already-affected workspace with the stale key. The client-side filter also fixes existing bad state.
    • De-dupe by accountID instead of email. Doesn't work — the orphan key has no real accountID; it falls back to generateAccountID(email), a hash of the string (WorkspaceMembersPage.tsx:347), which never collides with the primary's real accountID.
    Regression risk and what to test
    • tests/actions/PolicyMemberTest.ts:1086-1129 currently asserts that both the primary and secondary keys live in employeeList. It will need updating for change 2.
    • Removing a member invited by secondary login relies on the pairing loop at Member.ts:396-408. Verify removal still works after the filter.
    • WorkspaceMemberDetailsPage.tsx:98-107 recovers a member whose route accountID came from the secondary login — make sure deep links still resolve.
    • Separate pre-existing bug spotted nearby: dismissAddedWithPrimaryLoginMessages sets primaryLoginsInvited: null (Policy.ts:4363). Once the banner is dismissed the pairing map is gone, so today the orphan row becomes unremovable. Change 2 makes this moot; change 1 alone does not.
    What I could not verify

    I confirmed the duplicate-row mechanism from code, but did not reproduce it at runtime (it needs two accounts, one with a validated secondary contact method). So I can't say from code alone whether the row is dimmed by OfflineWithFeedback opacity — which needs offline + pendingAction, or an error (OfflineWithFeedback.tsx:104-107) — or simply looks grey because of the fallback email-as-name and default avatar. Either way the row should not be there.

    Related issue

    #93732 (Workflows — approver invited by secondary login is rejected with 402 either a submitsTo or forwardsTo value is not a member of the policy) has the same root cause: the typed secondary login is passed straight through as submitsTo at ReportSubmitToContent.tsx:206-234. Change 3 (excluding secondary logins from pickers) would help there too, but that flow needs its own fix.


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


    view run · view recording

  4. added
    Daily
    and removed on Sep 5, 2026
  5. added
    External
    on Sep 5, 2026
  6. melvin-bot commented on Sep 5, 2026

    @melvin-bot

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

  7. melvin-bot commented on Sep 5, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  8. Eskalifer1 commented on Sep 7, 2026

    @Eskalifer1
    Contributor

    @MelvinBot I see that this issue is reproducible in BrowserStack tests—which means that this issue already existed before and was fixed. You can look up the issue or PR that addressed this in the past and see how they fixed it. It seems like someone might have simply overwritten their fix.

  9. MelvinBot commented on Sep 7, 2026

    @MelvinBot
    Contributor

    Eskalifer1 — you're right that this is a regression, with one twist: there was no earlier merged fix to overwrite. The thing that used to hide this row was accidental, and the one deliberate fix was closed unmerged.

    The regression is Expensify/App#98483 (merged 2026-08-24, production in 9.4.60-2 on 2026-08-25). It removed the if (!details) { continue; } guard in filteredMembers and replaced it with a synthetic identity — WorkspaceMembersPage.tsx:347-357. That guard was the only thing keeping the orphan secondary-login row invisible. This issue was filed 2026-08-29, four days after that hit production.

    Timeline

    When What
    2023-08-22 #22622 (a SelectionList refactor) leaves if (!details) { continue; } in the members loop. Not a de-dupe fix — incidental, and framed as a Log.hmmm anomaly. But it hides the ghost row, because the invite clears the secondary login's optimistic personal details on success, so the join comes up empty.
    2023-10-27 #23702 adds primaryLoginsInvited and the "Added by secondary login" caption for #21639. Its own PR body says the two keys are by design: "the member will be added with their secondary login optimistically, then get added by their primary (preferred) login." The caption was the accepted UX — the secondary key was never meant to render its own row.
    2024-11-14 #52517 reports this exact bug ("there appears to be two entries in the workspace's employeeList"), then rendering as Hidden rather than grey.
    2024-12-09 #53038 — a one-line fix, if (!accountID || isDeletedPolicyEmployee(...)) — is closed unmerged: "Just tried reproducing it locally and on staging and I'm seeing the correct expected behavior." The accidental guard had made it look already fixed.
    2025-12-08 #76523 fixes the removal side (#75514) — it sweeps the orphan key away when you remove the member, but never stopped it existing or rendering.
    2026-08-24 #98483 removes the guard. Production 9.4.60-2, 2026-08-25.
    2026-08-29 This issue, on v9.4.64-0.

    Recommended fix

    Don't revert #98483 — it fixed a real bug (#97591: members with genuinely missing personal details were being dropped from the list).

    Instead, keep the fallback but make it not apply to an employeeList key that policy.primaryLoginsInvited identifies as a secondary login whose primary is also present. The page already computes that map one line away, at WorkspaceMembersPage.tsx:331, purely to render the caption. This re-lands #53038's intent without re-dropping legitimately detail-less members.

    There is already in-repo precedent for reconciling the secondary key this way: #96449 at WorkspaceMemberDetailsPage.tsx:99, and #98483 itself adopted primaryLoginsInvited pairing in removeMembers.

    Why the row is grey, and one loose end

    The orphan key has no personal details, so :347-357 gives it a hashed generateAccountID(email) and the raw email as its display name, which means no avatar and no real name. In 2024 the same orphan rendered as Hidden instead, because Number('') was 0 and personalDetails[0] was a live key at the time — same bug, different cosmetics.

    Worth noting the asymmetry this created: the identical guard still exists at WorkspaceWorkflowsPayerPage.tsx:119-123, and in DynamicRoomMembersPage and AgentsPage. So the Payer list still hides this ghost while the Members page shows it. getMemberAccountIDsForWorkspace also still skips the orphan — #98483 bypassed it rather than changing it.

    Not verified

    I confirmed the timeline and the code path, but did not reproduce it at runtime — that needs two accounts, one with a validated secondary contact method. The version dates are from the release list (9.4.60-2 production 2026-08-25) rather than a deploy comment on the PR, since #98483 only got a staging comment.

    The root cause in my earlier proposal still stands — the invite flow keys employeeList by the typed email and never deletes that key. What's new is that the duplicate only became visible again because of #98483, so the fix belongs in filteredMembers rather than in the invite action.


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


    view run · no recording available

  10. Eskalifer1 commented on Sep 7, 2026

    @Eskalifer1
    Contributor

    @MelvinBot I don't think we should clean up successData because it could cause a lot more regressions, and it's not worth it—since the bug we're talking about here isn't really that critical and is more of an edge case. So please send me a code diff for the solution you're recommending here: #99823 (comment)

  11. 77 remaining items

  12. added
    Daily
    Awaiting Payment
    on Oct 11, 2026
  13. melvin-bot commented on Oct 11, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  14. melvin-bot commented on Oct 11, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  15. Eskalifer1 commented on Oct 12, 2026

    @Eskalifer1
    Contributor

    Contributor+ 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: https://github.com/Expensify/App/pull/98483/changes#r4245284460

    • [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: N/A

    • [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.

    Regression Test Proposal

    Precondition:

    • User A has set up a secondary contact in the account

    Test:

    1. Open the New Dot app as another Admin user of a Workspace
    2. Navigate to the Members page
    3. Invite the secondary contact of User A to the Workspace
    4. Verify that after the API is done, only primary contact of user A appears in the member list

    Do we agree 👍 or 👎

  16. Eskalifer1 commented on Oct 12, 2026

    @Eskalifer1
    Contributor

    Note for payment: Price for this issue should be 250$, sice it was created and worked on before introducing 175$ price update

    I'm getting paid via Upwork

  17. mallenexpensify commented on Oct 14, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor: @nkdengineer due $250 via NewDot
    Contributor+: @Eskalifer1 paid $250 via NewDot

    @Eskalifer1 can you please accept the job below? Please reply here and tag me once you have.
    https://www.upwork.com/jobs/~022110480109166281599

  18. Eskalifer1 commented on Oct 14, 2026

    @Eskalifer1
    Contributor

    Hi @mallenexpensify! I have accepted, thank you!

  19. mallenexpensify commented on Oct 15, 2026

    @mallenexpensify
    Contributor

    @Eskalifer1 paid, summary updated above. Thx.

  20. twisterdotcom commented on Oct 30, 2026

    @twisterdotcom
    Contributor

    $250 approved for @nkdengineer in Report ID: R00AgwJoQv11.

    Zapier Logs Run ID: 00040eee-1aeb-af35-a91a-e5f46ac68884

    SO: https://stackoverflowteams.com/c/expensify/questions/7582

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternalNot a priority

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions