Skip to content

[Payment due 12-17][$250] Workspace - Secondary login is shown as workspace member after removing member from workspace #75514

Closed

Description

@mitarachim

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.2.60-1
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: Exp https://test-management.browserstack.com/projects/2219752/test-runs/TR-2009/folder/13177080/41237947/1022757418
Email or phone of affected tester (no customers): applausetester+181103kh@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.5 / Chrome
App Component: Workspace Settings

Action Performed:

Precondition:

  • User B has secondary login.
  • Perform the steps below as User A:
  1. Go to staging.new.expensify.com
  2. Create a workspace.
  3. Go to workspace settings > Members.
  4. Click Invite member.
  5. Enter User B's secondary login.
  6. Select the secondary login and invite the user.
  7. Remove the invited user.
  8. Click Invite member.
  9. Enter User B's secondary login.
    BUG 1: User B's secondary login is displayed as "already a member of Workspace".
  10. Close the RHP.
  11. Go to workspace settings > Workflows.
  12. Click on the default approval workflow.
  13. Click Approver.
    BUG 2: User B's secondary login is still displayed on the list, when it should have been removed.

Expected Result:

BUG 1: User should be able to invite User B by secondary login after removing User B from the workspace.
BUG 2: User B's secondary login will not appear on the approver list, because User B is removed.

Actual Result:

BUG 1: User B's secondary login is displayed as "already a member of Workspace".
BUG 2: User B's secondary login is still displayed on the list, when it should have been removed.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7008071_1763542584706.21.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021991587643283375702
  • Upwork Job ID: 1991587643283375702
  • Last Price Increase: 2025-11-27
  • Automatic offers:
    • LorenzoBloedow | Contributor | 109671169
Issue OwnerCurrent Issue Owner: @amyevans

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Nov 19, 2025
  2. melvin-bot commented on Nov 19, 2025

    @melvin-bot

    Triggered auto assignment to @Christinadobrzyn (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Nov 20, 2025
  4. changed the title [-]Workspace - Secondary login is shown as workspace member after removing member from workspace[/-] [+][$250] Workspace - Secondary login is shown as workspace member after removing member from workspace[/+] on Nov 20, 2025
  5. melvin-bot commented on Nov 20, 2025

    @melvin-bot
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Nov 20, 2025
  7. melvin-bot commented on Nov 20, 2025

    @melvin-bot

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

  8. Christinadobrzyn commented on Nov 20, 2025

    @Christinadobrzyn
    Contributor

    I can reproduce with the steps in the OP - the steps are outline really well!

  9. LorenzoBloedow commented on Nov 23, 2025

    @LorenzoBloedow
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-11-28 14:57:54 UTC.

    Proposal

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

    After removing a user invited with a secondary login, it stays in the approval workflow menu and if you try to invite the same user the button gets disabled and you get "already a member of Workspace".

    What is the root cause of that problem?

    When inviting a user with the secondary login, we don't know it's a secondary login and not the primary, so, because of our optimistic design, we end up storing the secondary login in the policy's employeeList and then, when we call OPEN_WORKSPACE_MEMBERS_PAGE, the BE returns the primary login as an onyx update, so we end up with both logins.

    In addition to this, the BE never returns personal details data for the secondary login, so we're left with a "detached" login in employeeList because we can't associate it with the same account ID as the primary login returned by the BE.

    Because we now have both logins (one detached), after removing a user (the primary login) we're still left with the secondary login in employeeList, this is why we see it in the workflow approvers list and can't add them as a member again.

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

    Detect and remove duplicate members when removing regular members:

    // Handles the case when there are multiple logins for the same account.
        // Currently, the only known case where this happens is when a user gets invited
        // with their secondary login.
        // This happens because we only have the secondary login when
        // we're inviting the user, but the backend always returns the primary login, 
        // so we end up with both stored in Onyx.
        const selectedMemberEmailsWithDuplicates: string[] = [...selectedMemberEmails];
        for (const employeeEmail of Object.keys(policy?.employeeList ?? {})) {
            const personalDetails = getPersonalDetailByEmail(employeeEmail);
            // If we don't have the personal details, it means it's a secondary login
            if (personalDetails) {
                continue;
            }
            selectedMemberEmailsWithDuplicates.push(employeeEmail);
        }
    
        for (const email of selectedMemberEmailsWithDuplicates) {

    Put this here:

    const optimisticMembersState: OnyxCollectionInputValue<PolicyEmployee> = {};
    const successMembersState: OnyxCollectionInputValue<PolicyEmployee> = {};
    const failureMembersState: OnyxCollectionInputValue<PolicyEmployee> = {};
    for (const email of selectedMemberEmails) {

    What alternative solutions did you explore? (Optional)

    • We could try filtering by account IDs and ignore employeeList, like it's being done in the members list already. Doesn't sound like the best idea though, employeeList is being used here probably for a reason.

    • We could also try setting the employeeList instead of merging (BE change) so whenever we call OPEN_WORKSPACE_MEMBERS_PAGE we get the entire employeeList with just the primary logins and override the local one. This might not scale well to policies with many members though.

    • We could use a middleware as shown in my previous proposal, but I have identified 1 bug with that approach where we can invite the same user twice if we use the secondary login.

    Result:

    secondary-login-fix.mov
  10. Christinadobrzyn commented on Nov 24, 2025

    @Christinadobrzyn
    Contributor

    hi @akinwale can you please check out the above proposal? TY!

  11. 22 remaining items

  12. Christinadobrzyn commented on Dec 12, 2025

    @Christinadobrzyn
    Contributor

    I'll be ooo until 12/21. Adding a BZ teammate to pay this out when the time comes.

  13. removed
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 12, 2025
  14. removed their assignment
    on Dec 12, 2025
  15. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 12, 2025
  16. melvin-bot commented on Dec 12, 2025

    @melvin-bot

    Triggered auto assignment to @JmillsExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  17. Christinadobrzyn commented on Dec 12, 2025

    @Christinadobrzyn
    Contributor

    @JmillsExpensify this is going to need to be paid while I'm ooo if you can help with that!

    Payment Summary

    Contributor: @LorenzoBloedow paid $250 via Upwork offer
    Contributor+: @akinwale due $250 via NewDot

    @akinwale do we need a regression test?

  18. akinwale commented on Dec 15, 2025

    @akinwale
    Contributor

    BugZero Checklist:

    • [@akinwale] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: N/A

    • [@akinwale] 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:

    • [@akinwale] 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:

    Regression Test Proposal

    Test:

    1. Launch Expensify.
    2. Invite a user to a workspace using their secondary login.
    3. Verify the user has been added to the workspace.
    4. Try inviting the user again using the same login used in step 1.
    5. Verify that the same user cannot be invited because they're already a member of the workspace.
    6. Remove the user from the workspace.
    7. Try inviting the user again using the same login used in step 1.
    8. Verify that the user has been added to the workspace.
    9. Remove the user from the workspace.
    10. Navigate to Workspace settings > Workflows > Add approvals > Default workflow > Approver.
    11. Verify that both the primary and secondary login of the user you just removed do not show up in the list.

    Do we agree 👍 or 👎?

  19. JmillsExpensify commented on Dec 17, 2025

    @JmillsExpensify
    Contributor

    Upwork contract paid out. Please request via ND!

  20. quinthar commented on Dec 18, 2025

    @quinthar
    Contributor

    Approved $250 to @akinwale

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions