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
Company card- Can assign the same card Wells Fargo direct feed for 2 workspaces #82554
Version Number: v9.3.18-6 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/TR-5132/folder/13176706/41236862/1186705757 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Win 11/Chrome App Component: Workspace Settings
Action Performed:
Precondition: Create 2 workspaces added Plaid - Wells Fargo direct feed with select Plaid credit card 3333
Open app
Navigate to Company card of the first workspace
Assign Plaid credit card 3333 for admin
Navigate to Company card of the second workspace
Assign Plaid credit card 3333 for employee
Expected Result:
Error should display when assign the same Plaid credit card 3333 for second workspace
Actual Result:
User can assign Plaid credit card 3333 for second workspace
Please re-state the problem that we are trying to solve in this issue.
When someone assigns a direct-feed company card in one workspace, the app does not detect that the same card is already assigned in another workspace. Because of that, the same direct-feed card can be assigned twice, which should not happen.
What is the root cause of that problem?
The root cause is in isCardAlreadyAssigned() in src/libs/CardUtils.ts.
The function previously filtered card-feed entries strictly to feedDomainID === domainOrWorkspaceAccountID for every call. In the assign-card confirmation flow, ConfirmationStep.submit() called this function without any mode that allows cross-workspace scanning for direct feeds, so cards assigned in other workspace accounts were not considered duplicates.
What changes do you think we should make in order to solve the problem?
Update isCardAlreadyAssigned() to support two explicit behaviors:
default behavior: preserve current scope-limited check for non-direct feeds
direct-feed behavior: allow checking across all workspace accounts by adding a new boolean argument (shouldCheckAcrossAllWorkspaceAccounts, default false)
In ConfirmationStep.submit(), pass isDirectFeed(feed) as that new argument so direct feeds use cross-workspace duplicate detection while other feeds keep current behavior.
Keep existing matching and safety behavior unchanged:
continue matching by encrypted number or card display name
continue skipping cards pending deletion
continue rejecting malformed Onyx keys
Lock this behavior with unit tests in CardUtilsTest that verify:
default mode only checks the provided workspace account
cross-workspace mode finds duplicates in other workspace accounts
cross-workspace mode still ignores cards pending deletion
Expected outcome: when assigning a direct-feed card, the app blocks assignment if that card is already assigned in any workspace account within the relevant domain/workspace-account scope; behavior for non-direct feeds remains unchanged.
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
Assigning the same Plaid direct-feed credit card across two different workspaces succeeds silently instead of showing the "card already assigned" error.
What is the root cause of that problem?
There is a behavioral inconsistency between card selection and card confirmation for direct feeds.
During card selection, getFilteredCardList() correctly collects assigned cards from every workspace and filters them out — so the card dropdown already hides cross-workspace duplicates:
However, the confirmation-step validation does not follow the same pattern. getDomainOrWorkspaceAccountID() returns cardFeedData.domainID ?? workspaceAccountID. Direct feeds lack a shared domainID, so each workspace resolves to its own isolated account ID:
That isolated ID is then passed into the duplicate check, which uses it to scope its scan to a single workspace. Cards assigned under a different workspace account are skipped entirely, so the duplicate goes undetected at confirmation time.
What changes do you think we should make in order to solve the problem?
Align the confirmation validation with the selection filtering by making the duplicate check feed-type-aware:
In isCardAlreadyAssigned() (src/libs/CardUtils.ts), accept the feed name as a new parameter. Use the existing isDirectFeed() utility to decide whether the domain-scoped guard applies: for direct feeds, bypass it so all workspace entries are scanned; for commercial feeds, keep the current scoped behavior unchanged.
In ConfirmationStep.submit() (src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx), forward the feed value (already available via route.params.feed) into the updated duplicate-check call.
This brings the confirmation validation in line with the cross-workspace approach getFilteredCardList() already uses at the selection step.
What alternative solutions did you explore? (Optional)
A generic boolean toggle would also work, but passing the feed name lets the function decide internally via isDirectFeed(), keeping the call site simple and the logic tied to the actual feed type rather than an opaque flag.
Please re-state the problem that we are trying to solve in this issue.
User can assign Plaid credit card 3333 for second workspace
What is the root cause of that problem?
The code checks cardFeedKeyParts.at(0) !== ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, which compares "cards" vs "cards_" (with trailing underscore). This never matches, so the function silently skips every entry and always returns false.
Additionally, cardFeedKeyParts.length !== 3 fails for Plaid feeds (e.g we have Onyx key: "cards_12345_plaid.ins_19", length in this case is 4 due to underscore in plaid.ins_19).
Even the bug above were fixed, feedDomainID !== domainOrWorkspaceAccountID explicitly skips cards from other workspaces. Since each workspace has a unique domain ID, Plaid cards assigned in workspace 1 are invisible when checking from workspace 2.
Fix cross-workspace check:
For direct feeds (Plaid/OAuth), check across all workspaces with the same feed name. For commercial feeds, keep domain-scoped check to avoid false positives.
Introduce new param feedName and pass bankName in ConfimationStep.tsx
Update isCardAlreadyAssigned function
Please re-state the problem that we are trying to solve in this issue.
A user can assign the same Wells Fargo (or other direct feed) company card to two different workspaces, when this should be blocked. The duplicate-assignment guard at confirmation time silently fails and always permits the assignment.
What is the root cause of that problem?
The root cause is in isCardAlreadyAssigned() in src/libs/CardUtils.ts (lines 1109–1134). The function contains a fatal string comparison bug that makes it always return false, completely disabling the duplicate check.
The Onyx key format is cards_<fundID>_<bankName> (e.g. cards_12345_oauth.chase.com). The function splits the key on _ and then checks cardFeedKeyParts.at(0) !== ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST. However, ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST is "cards_" (with a trailing underscore), while splitting on _ produces "cards" as the first element. Since "cards" !== "cards_" is always true, the early-return guard always fires and the function always returns false.
A second issue compounds this: the feedDomainID !== domainOrWorkspaceAccountID filter on line 1125 would prevent cross-workspace detection even if the parsing were fixed, because each workspace has its own unique account ID. So a card assigned in workspace A would never be flagged when assigning to workspace B. The caller in ConfirmationStep.tsx passes domainOrWorkspaceAccountID which further scopes the check to only the current workspace.
What changes do you think we should make in order to solve the problem?
Fix isCardAlreadyAssigned() in src/libs/CardUtils.ts with two changes:
Replace the broken split('_')[0] !== ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST check with key.startsWith(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST) to correctly validate Onyx keys.
Remove the domainOrWorkspaceAccountID filter entirely so the function scans all workspace card feeds, enabling cross-workspace duplicate detection.
Remove the domainOrWorkspaceAccountID argument from the call site in ConfirmationStep.tsx (line 110) to match the updated signature.
What alternative solutions did you explore? (Optional)
An alternative is to keep the domain-scoped filter but add a shouldCheckAcrossAllWorkspaces flag (as proposed by ubaidsk/HiepPP), only bypassing the domain filter for direct feeds. This is more conservative but adds complexity. Since the simplest correct behavior is to check all workspaces globally (matching how getFilteredCardList() already works at the selection step), removing the filter entirely is the cleaner fix.
Please re-state the problem that we are trying to solve in this issue.
A Plaid Wells Fargo direct-feed credit card can be assigned to more than one workspace because when the same card is already assigned in Workspace A, the app still allows assigning it again in Workspace B instead of blocking the second assignment and showing an error.
What is the root cause of that problem?
In this implementation, submit() in src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx assumes one identifier is enough when calling CardUtils.isCardAlreadyAssigned, but the same physical Plaid card can be represented in different workspaces by different fields (encryptedCardNumber in one feed and cardName in another), so passing only cardToAssign?.encryptedCardNumber ?? cardToAssign?.cardName can miss the existing assignment and fail to enforce the “already assigned in any workspace” rule implemented in src/libs/CardUtils.ts in isCardAlreadyAssigned.
What changes do you think we should make in order to solve the problem?
Pass both encryptedCardNumber and cardName into the existing helper so the same card is detected in any workspace regardless of which field is stored there, by extending the utility to accept multiple identifiers while keeping a single call at the call site.
src/libs/CardUtils.ts — isCardAlreadyAssigned
Change the first parameter from string to string | string[].
Normalize to an array (filter empty); if the array is empty or workspaceCardFeeds is missing, return false.
For each workspace feed and each assigned card (excluding pending delete), return true if any of the given identifiers equals card.encryptedCardNumber or card.cardName.
Passing a single string remains valid (normalize to a one-element array).
Build an array of both identifiers: [cardToAssign?.encryptedCardNumber, cardToAssign?.cardName].filter(Boolean).
Call isCardAlreadyAssigned(cardIdentifiers, workspaceCardFeeds). If true, set the existing error workspace.companyCards.cardAlreadyAssignedError and return without calling assignWorkspaceCompanyCard.
Scope: Two files only. No new Onyx keys, no API changes, no new translation keys. Regression risk is limited to the assign-card confirmation flow; the single existing caller of isCardAlreadyAssigned continues to work when passed a single string.
What alternative solutions did you explore? (Optional)
Calling isCardAlreadyAssigned twice in ConfirmationStep (once per identifier): Would work but duplicates the “already assigned” logic at the call site; extending the utility keeps the rule in one place.
Backend-only enforcement: Does not fix the case where the client already has the other workspace’s data; can be added later as a complement.
Guard elsewhere (e.g. before navigation): Would duplicate the same rule; the single check at submit with both identifiers is sufficient.
New selector or Onyx shape: Not needed; WORKSPACE_CARDS_LIST and isCardAlreadyAssigned already support “any workspace”; the fix is to pass both identifiers.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
Activity
melvin-bot commentedon Feb 16, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @suneox (
External)melvin-bot commentedon Feb 16, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
melvin-bot commentedon Feb 16, 2026
Triggered auto assignment to @CortneyOfstad (
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.ubaidsk commentedon Feb 16, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When someone assigns a direct-feed company card in one workspace, the app does not detect that the same card is already assigned in another workspace. Because of that, the same direct-feed card can be assigned twice, which should not happen.
What is the root cause of that problem?
The root cause is in
isCardAlreadyAssigned()insrc/libs/CardUtils.ts.https://github.com/Expensify/App/blob/19cf92bcd2a/src/libs/CardUtils.ts#L1109-L1143
The function previously filtered card-feed entries strictly to
feedDomainID === domainOrWorkspaceAccountIDfor every call. In the assign-card confirmation flow,ConfirmationStep.submit()called this function without any mode that allows cross-workspace scanning for direct feeds, so cards assigned in other workspace accounts were not considered duplicates.https://github.com/Expensify/App/blob/19cf92bcd2a/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx#L94-L125
What changes do you think we should make in order to solve the problem?
isCardAlreadyAssigned()to support two explicit behaviors:shouldCheckAcrossAllWorkspaceAccounts, defaultfalse)ConfirmationStep.submit(), passisDirectFeed(feed)as that new argument so direct feeds use cross-workspace duplicate detection while other feeds keep current behavior.CardUtilsTestthat verify:https://github.com/Expensify/App/blob/19cf92bcd2a/tests/unit/CardUtilsTest.ts#L2711-L2763
Expected outcome: when assigning a direct-feed card, the app blocks assignment if that card is already assigned in any workspace account within the relevant domain/workspace-account scope; behavior for non-direct feeds remains unchanged.
What alternative solutions did you explore? (Optional)
HiepPP commentedon Feb 16, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
Assigning the same Plaid direct-feed credit card across two different workspaces succeeds silently instead of showing the "card already assigned" error.
What is the root cause of that problem?
There is a behavioral inconsistency between card selection and card confirmation for direct feeds.
During card selection,
getFilteredCardList()correctly collects assigned cards from every workspace and filters them out — so the card dropdown already hides cross-workspace duplicates:App/src/libs/CardUtils.ts
Lines 799 to 811 in 317057c
However, the confirmation-step validation does not follow the same pattern.
getDomainOrWorkspaceAccountID()returnscardFeedData.domainID ?? workspaceAccountID. Direct feeds lack a shareddomainID, so each workspace resolves to its own isolated account ID:App/src/libs/CardUtils.ts
Lines 717 to 719 in 317057c
That isolated ID is then passed into the duplicate check, which uses it to scope its scan to a single workspace. Cards assigned under a different workspace account are skipped entirely, so the duplicate goes undetected at confirmation time.
App/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx
Line 62 in 317057c
What changes do you think we should make in order to solve the problem?
Align the confirmation validation with the selection filtering by making the duplicate check feed-type-aware:
In
isCardAlreadyAssigned()(src/libs/CardUtils.ts), accept the feed name as a new parameter. Use the existingisDirectFeed()utility to decide whether the domain-scoped guard applies: for direct feeds, bypass it so all workspace entries are scanned; for commercial feeds, keep the current scoped behavior unchanged.In
ConfirmationStep.submit()(src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx), forward thefeedvalue (already available viaroute.params.feed) into the updated duplicate-check call.App/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx
Line 43 in 317057c
This brings the confirmation validation in line with the cross-workspace approach
getFilteredCardList()already uses at the selection step.What alternative solutions did you explore? (Optional)
A generic boolean toggle would also work, but passing the feed name lets the function decide internally via
isDirectFeed(), keeping the call site simple and the logic tied to the actual feed type rather than an opaque flag.paulnjs commentedon Feb 16, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
User can assign Plaid credit card 3333 for second workspace
What is the root cause of that problem?
The code checks
cardFeedKeyParts.at(0) !== ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, which compares "cards" vs "cards_" (with trailing underscore). This never matches, so the function silently skips every entry and always returns false.App/src/libs/CardUtils.ts
Line 1121 in 317057c
Additionally, cardFeedKeyParts.length !== 3 fails for Plaid feeds (e.g we have
Onyx key: "cards_12345_plaid.ins_19", length in this case is 4 due to underscore in plaid.ins_19).Even the bug above were fixed,
feedDomainID !== domainOrWorkspaceAccountIDexplicitly skips cards from other workspaces. Since each workspace has a unique domain ID, Plaid cards assigned in workspace 1 are invisible when checking from workspace 2.App/src/libs/CardUtils.ts
Line 1125 in 317057c
What changes do you think we should make in order to solve the problem?
For key parsing:
Use
key.replace(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, '') + split on first _ only (matching the pattern inApp/src/selectors/Card.ts
Line 34 in 317057c
Fix cross-workspace check:
For direct feeds (Plaid/OAuth), check across all workspaces with the same feed name. For commercial feeds, keep domain-scoped check to avoid false positives.
Introduce new param
feedNameand pass bankName inConfimationStep.tsxUpdate
isCardAlreadyAssignedfunctionApp/src/libs/CardUtils.ts
Lines 1114 to 1127 in 317057c
to:
What alternative solutions did you explore? (Optional)
N/A
Screen.Recording.2026-02-16.at.21.08.52.mov
twilight2294 commentedon Feb 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
A user can assign the same Wells Fargo (or other direct feed) company card to two different workspaces, when this should be blocked. The duplicate-assignment guard at confirmation time silently fails and always permits the assignment.
What is the root cause of that problem?
The root cause is in
isCardAlreadyAssigned()insrc/libs/CardUtils.ts(lines 1109–1134). The function contains a fatal string comparison bug that makes it always returnfalse, completely disabling the duplicate check.The Onyx key format is
cards_<fundID>_<bankName>(e.g.cards_12345_oauth.chase.com). The function splits the key on_and then checkscardFeedKeyParts.at(0) !== ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST. However,ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LISTis"cards_"(with a trailing underscore), while splitting on_produces"cards"as the first element. Since"cards" !== "cards_"is alwaystrue, the early-return guard always fires and the function always returnsfalse.https://github.com/Expensify/App/blob/main/src/libs/CardUtils.ts#L1109-L1134
A second issue compounds this: the
feedDomainID !== domainOrWorkspaceAccountIDfilter on line 1125 would prevent cross-workspace detection even if the parsing were fixed, because each workspace has its own unique account ID. So a card assigned in workspace A would never be flagged when assigning to workspace B. The caller inConfirmationStep.tsxpassesdomainOrWorkspaceAccountIDwhich further scopes the check to only the current workspace.https://github.com/Expensify/App/blob/main/src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx#L107-L113
What changes do you think we should make in order to solve the problem?
Fix
isCardAlreadyAssigned()insrc/libs/CardUtils.tswith two changes:split('_')[0] !== ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LISTcheck withkey.startsWith(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST)to correctly validate Onyx keys.domainOrWorkspaceAccountIDfilter entirely so the function scans all workspace card feeds, enabling cross-workspace duplicate detection.The simplified function would look like:
Remove the
domainOrWorkspaceAccountIDargument from the call site inConfirmationStep.tsx(line 110) to match the updated signature.What alternative solutions did you explore? (Optional)
An alternative is to keep the domain-scoped filter but add a
shouldCheckAcrossAllWorkspacesflag (as proposed by ubaidsk/HiepPP), only bypassing the domain filter for direct feeds. This is more conservative but adds complexity. Since the simplest correct behavior is to check all workspaces globally (matching howgetFilteredCardList()already works at the selection step), removing the filter entirely is the cleaner fix.yatin-italy commentedon Feb 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
A Plaid Wells Fargo direct-feed credit card can be assigned to more than one workspace because when the same card is already assigned in Workspace A, the app still allows assigning it again in Workspace B instead of blocking the second assignment and showing an error.
What is the root cause of that problem?
In this implementation,
submit()insrc/pages/workspace/companyCards/assignCard/ConfirmationStep.tsxassumes one identifier is enough when callingCardUtils.isCardAlreadyAssigned, but the same physical Plaid card can be represented in different workspaces by different fields (encryptedCardNumberin one feed andcardNamein another), so passing onlycardToAssign?.encryptedCardNumber ?? cardToAssign?.cardNamecan miss the existing assignment and fail to enforce the “already assigned in any workspace” rule implemented insrc/libs/CardUtils.tsinisCardAlreadyAssigned.What changes do you think we should make in order to solve the problem?
Pass both
encryptedCardNumberandcardNameinto the existing helper so the same card is detected in any workspace regardless of which field is stored there, by extending the utility to accept multiple identifiers while keeping a single call at the call site.src/libs/CardUtils.ts—isCardAlreadyAssignedstringtostring | string[].workspaceCardFeedsis missing, returnfalse.trueif any of the given identifiers equalscard.encryptedCardNumberorcard.cardName.src/pages/workspace/companyCards/assignCard/ConfirmationStep.tsx—submit()[cardToAssign?.encryptedCardNumber, cardToAssign?.cardName].filter(Boolean).isCardAlreadyAssigned(cardIdentifiers, workspaceCardFeeds). If true, set the existing errorworkspace.companyCards.cardAlreadyAssignedErrorand return without callingassignWorkspaceCompanyCard.Scope: Two files only. No new Onyx keys, no API changes, no new translation keys. Regression risk is limited to the assign-card confirmation flow; the single existing caller of
isCardAlreadyAssignedcontinues to work when passed a single string.What alternative solutions did you explore? (Optional)
Calling
isCardAlreadyAssignedtwice inConfirmationStep(once per identifier): Would work but duplicates the “already assigned” logic at the call site; extending the utility keeps the rule in one place.Backend-only enforcement: Does not fix the case where the client already has the other workspace’s data; can be added later as a complement.
Guard elsewhere (e.g. before navigation): Would duplicate the same rule; the single check at submit with both identifiers is sufficient.
New selector or Onyx shape: Not needed;
WORKSPACE_CARDS_LISTandisCardAlreadyAssignedalready support “any workspace”; the fix is to pass both identifiers.16 remaining items
suneox commentedon Mar 16, 2026
@CortneyOfstad The PR was deployed to production over a week ago, so this issue is ready for payment.
melvin-bot commentedon Mar 20, 2026
This issue has not been updated in over 15 days. @youssef-lr, @CortneyOfstad, @suneox, @paulnjs eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
suneox commentedon Mar 24, 2026
@CortneyOfstad This issue is ready for payment
melvin-bot commentedon Mar 31, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)CortneyOfstad commentedon Mar 31, 2026
@paulnjs — I sent you an offer here. Please let me know once you accept and I'll get that paid ASAP.
Regression test
Will do a proper payment summary when offer is accepted
paulnjs commentedon Apr 1, 2026
@CortneyOfstad I accepted the offer. Thank you!
mallenexpensify commentedon Apr 2, 2026
Payment Summary
Contributor: @paulnjs paid $250 via Upwork
Contributor+: @suneox due $250 via NewDot
Thx
trjExpensify commentedon Apr 2, 2026
approved $250 for @suneox