Skip to content

[Due for payment 2026-08-25] Assigned company card is named using the admin's account instead of the employee's account #97692

Closed

Description

@m-natarajan

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


Version Number:
Reproducible in staging?: Needs Reproduction (Unable to reproduce)
Reproducible in production?: Needs Reproduction
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @quinthar
Slack conversation (hyperlinked to channel name): #Migrate

Action Performed:

  1. Sign in as a workspace admin.
  2. Navigate to Workspace > Company Cards > CSV feed.
  3. Assign an unassigned company card to another employee.
  4. Observe the generated card name in the Assign card RHP.

Expected Result:

The card name should be named using the employee's account, since the card belongs to that employee.

Actual Result:

The card name is named using the admin's account that performed the assignment

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

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

Screenshots/Videos

Image

View all open jobs on GitHub

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 3, 2026
  2. MelvinBot commented on Aug 3, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The assign-card flow bakes the admin's name into customCardName before the admin ever picks the real cardholder, and then a set of guards refuse to recompute it once it's set. Two cooperating defects:

    1. The single-employee shortcut pre-fills the card name from the wrong member. In useAssignCard.ts:200-212, when the workspace resolves to a single non-deleted employee the flow skips the Assignee step and jumps straight to Confirmation, pre-setting both email and customCardName. On a fresh CSV-feed workspace that single member is typically the admin, so the card is named "<admin>'s card". There's also a filtered/unfiltered mismatch: the length === 1 check runs on the filtered (non-deleted) list, but userEmail = Object.keys(policy.employeeList).at(0) reads the unfiltered first key — so it can pick the wrong (admin) email even when the counted employee is someone else.

    2. Stale guards never recompute the name when the assignee changes. AssigneeStep.tsx:92 only sets the name ...(!assignCard?.cardToAssign?.customCardName ? {customCardName: defaultCardName} : {}), and lines 103/139 use customCardName ?? defaultCardName. So once the admin's name is stored, editing the assignee to another employee leaves the admin's name in place. The Confirmation RHP renders that stored value (ConfirmationStep.tsx:211) and it's sent to the backend as cardName (CompanyCards.ts:469).

    Evidence & data flow
    • The name generator: CardUtils.ts:1154-1159 → `${cardholder}'s card`. memberName falls back to the raw login/email when firstName is empty, which is why the symptom reads as the admin's account/email.
    • Flow: click Assign → useAssignCard.assignCard() → getInitialAssignCardStep(). Single-member → auto-fills email+customCardName, routes to CONFIRMATION. Multi-member → routes to ASSIGNEE, where the name is correctly derived from the selected assignee (AssigneeStep.tsx:87-89) — that path alone is fine.
    • The bug fires when customCardName is already populated (admin) and the admin then selects/changes the assignee: the guards refuse to recompute.
    • Related/secondary: InviteNewMemberStep.tsx:62 passes an email (invitingMemberEmail) into getDefaultCardName, producing "<email>'s card" instead of "<Name>'s card" — inconsistent with AssigneeStep, worth fixing in the same pass.

    Note: I confirmed this by static code analysis (deterministic front-end Onyx state — no server logs involved). I did not spin up a live CSV feed to reproduce, since that requires specific workspace/feed provisioning. Confidence is medium-high.

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

    1. Fix the member selection in the single-employee shortcut (useAssignCard.ts:200-212): derive userEmail from the same filtered list used for the length === 1 check (e.g. filter Object.entries(policy.employeeList) and take the surviving entry's email) so the auto-assign always targets the single active member, not the unfiltered first key.

    2. Make the card name follow the current assignee in AssigneeStep.tsx: recompute customCardName from the newly-selected assignee instead of keeping the previously-stored value (drop/adjust the guards at lines 92, 103, 139). To avoid clobbering a name the user manually typed in CardNameStep, track whether the name was user-edited and only skip the recompute in that case.

    What alternative solutions did you explore? (Optional)

    Only recomputing at the Confirmation/submit step (from cardToAssign.email) instead of touching the Assignee guards — this centralizes the fix but doesn't correct the name the user sees in the intermediate steps, so fixing it at the source (assignee selection) is preferable.


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

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 3, 2026
  4. melvin-bot commented on Aug 3, 2026

    @melvin-bot

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

  5. melvin-bot commented on Aug 3, 2026

    @melvin-bot
  6. j3ffffff commented on Aug 3, 2026

    @j3ffffff
  7. QichenZhu commented on Aug 4, 2026

    @QichenZhu
    Contributor

    Reproduced this another way. I assigned the card to the admin, but the name was another user:

    Screen.Recording.2026-08-04.at.2.09.30.PM.mov
  8. QichenZhu commented on Aug 4, 2026

    @QichenZhu
    Contributor

    @MelvinBot's RCA mistakenly says the flow skips the Assignee step and goes straight to Confirmation, which isn't true, but the main idea is valid, and both solutions work in my testing, so I'm good with @MelvinBot's proposal.

    🎀 👀 🎀 C+ reviewed

  9. melvin-bot commented on Aug 4, 2026

    @melvin-bot

    Triggered auto assignment to @carlosmiceli, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  10. MelvinBot commented on Aug 4, 2026

    @MelvinBot
    Contributor

    You're right, and thanks for the correction — my RCA overstated the single-employee shortcut. That shortcut (useAssignCard.ts:201-212) does route straight to Confirmation, but it isn't the path the reported bug reproduces on. The operative mechanism is defect #2: the flow goes through the Assignee step, and the guard at AssigneeStep.tsx:92 (...(!customCardName ? {customCardName: defaultCardName} : {}), plus the customCardName ?? defaultCardName fallbacks at 103/139) never recomputes the name once one is stored — so switching the assignee (your repro: assign to admin, name stays another user) leaves the earlier name in place.

    So the key fix stays fix #2: make the card name follow the current assignee instead of preserving the stored value, while still respecting a name the user manually typed in CardNameStep. Fix #1 (filtered vs. unfiltered email in the single-member shortcut) is a smaller edge-case correction and still worth including. Glad both work in your testing.

  11. QichenZhu commented on Aug 4, 2026

    @QichenZhu
    Contributor

    That shortcut (useAssignCard.ts:201-212) does route straight to Confirmation

    @MelvinBot, that's incorrect. Have you tested it?

    Screen.Recording.2026-08-04.at.4.44.49.PM.mov
  12. 24 remaining items

  13. melvin-bot commented on Aug 21, 2026

    @melvin-bot

    @QichenZhu Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  14. QichenZhu commented on Aug 24, 2026

    @QichenZhu
    Contributor

    Contributor+ Checklist:

    Regression Test Proposal

    Precondition:

    • A workspace has a CSV/commercial feed and at least one admin and one member

    Test:

    1. Log in as the admin
    2. Go to Workspace settings > Company cards and select a CSV/commercial feed
    3. Tap Assign on an unassigned card
    4. Select the member and tap Next
    5. Verify that the card name is [member's name]'s card
    6. Go back, select the admin, and tap Next
    7. Verify that the card name is [admin's name]'s card
    8. Tap Card name, change it to a different value, and save
    9. Go back, select the member, and tap Next
    10. Verify that the manually edited card name is preserved

    Do we agree 👍 or 👎

  15. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Aug 24, 2026
  16. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  17. melvin-bot commented on Aug 24, 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
  18. mallenexpensify commented on Aug 26, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @QichenZhu due $250 via NewDot

  19. moved this from MEDIUM or LOW to Done in [#whatsnext] #migrateon Aug 26, 2026
  20. trjExpensify commented on Sep 1, 2026

    @trjExpensify
    Contributor

    approved $250 for @QichenZhu

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