You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-08-25] Assigned company card is named using the admin's account instead of the employee's account #97692
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:
Sign in as a workspace admin.
Navigate to Workspace > Company Cards > CSV feed.
Assign an unassigned company card to another employee.
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:
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?
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.
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.
@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.
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.
[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.
[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:
A workspace has a CSV/commercial feed and at least one admin and one member
Test:
Log in as the admin
Go to Workspace settings > Company cards and select a CSV/commercial feed
Tap Assign on an unassigned card
Select the member and tap Next
Verify that the card name is [member's name]'s card
Go back, select the admin, and tap Next
Verify that the card name is [admin's name]'s card
Tap Card name, change it to a different value, and save
Go back, select the member, and tap Next
Verify that the manually edited card name is preserved
Activity
MelvinBot commentedon Aug 3, 2026
Proposal
What is the root cause of that problem?
The assign-card flow bakes the admin's name into
customCardNamebefore 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 bothemailandcustomCardName. 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: thelength === 1check runs on the filtered (non-deleted) list, butuserEmail = 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:92only sets the name...(!assignCard?.cardToAssign?.customCardName ? {customCardName: defaultCardName} : {}), and lines103/139usecustomCardName ?? 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 ascardName(CompanyCards.ts:469).Evidence & data flow
CardUtils.ts:1154-1159→`${cardholder}'s card`.memberNamefalls back to the rawlogin/email whenfirstNameis empty, which is why the symptom reads as the admin's account/email.useAssignCard.assignCard()→getInitialAssignCardStep(). Single-member → auto-fillsemail+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.customCardNameis already populated (admin) and the admin then selects/changes the assignee: the guards refuse to recompute.InviteNewMemberStep.tsx:62passes an email (invitingMemberEmail) intogetDefaultCardName, producing"<email>'s card"instead of"<Name>'s card"— inconsistent withAssigneeStep, 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?
Fix the member selection in the single-employee shortcut (
useAssignCard.ts:200-212): deriveuserEmailfrom the same filtered list used for thelength === 1check (e.g. filterObject.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.Make the card name follow the current assignee in
AssigneeStep.tsx: recomputecustomCardNamefrom 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 inCardNameStep, 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.
melvin-bot commentedon Aug 3, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @QichenZhu (
External)melvin-bot commentedon Aug 3, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022084277784406682899
j3ffffff commentedon Aug 3, 2026
QichenZhu commentedon Aug 4, 2026
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
QichenZhu commentedon Aug 4, 2026
@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
melvin-bot commentedon Aug 4, 2026
Triggered auto assignment to @carlosmiceli, see https://stackoverflow.com/c/expensify/questions/7972 for more details.
MelvinBot commentedon Aug 4, 2026
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 atAssigneeStep.tsx:92(...(!customCardName ? {customCardName: defaultCardName} : {}), plus thecustomCardName ?? defaultCardNamefallbacks at103/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.QichenZhu commentedon Aug 4, 2026
@MelvinBot, that's incorrect. Have you tested it?
Screen.Recording.2026-08-04.at.4.44.49.PM.mov
24 remaining items
melvin-bot commentedon Aug 21, 2026
@QichenZhu Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
QichenZhu commentedon Aug 24, 2026
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: Fix card assignment flow when members are changed #53550 (comment)
Link to the comment on the Issue: [HOLD for payment 2024-12-16] Card assignment cleanup, multiple members down to one #53469 (comment)
[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:
Test:
Do we agree 👍 or 👎
melvin-bot commentedon Aug 24, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Aug 24, 2026
Payment Summary
Resolving PRs:
Name assigned company card after the selected employee, not the admin #97925
Reviewer: @QichenZhu owed $250 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Aug 26, 2026
Payment Summary
Contributor+: @QichenZhu due $250 via NewDot
trjExpensify commentedon Sep 1, 2026
approved $250 for @QichenZhu