Skip to content

Fix company card assignment for commercial cards feed#79625

Merged
joekaufmanexpensify merged 40 commits intoExpensify:mainfrom
fedirjh:fix-invalid-encryptedCardNumber
Jan 20, 2026
Merged

Fix company card assignment for commercial cards feed#79625
joekaufmanexpensify merged 40 commits intoExpensify:mainfrom
fedirjh:fix-invalid-encryptedCardNumber

Conversation

@fedirjh
Copy link
Contributor

@fedirjh fedirjh commented Jan 15, 2026

Explanation of Change

Fixed a bug in the company cards assignment flow where the encryptedCardNumber was incorrectly being passed for feed cards.

Fixed Issues

$ #79221
PROPOSAL:

Tests

Test 1:

  1. Connect a custom feed (e.g., commercial card feed) to a workspace
  2. Navigate to the company cards page
  3. Click "Assign card" on an unassigned card
  4. Complete the assignment flow
  5. Verify the card is assigned successfully without errors

  1. Connect a direct feed (e.g., Plaid or OAuth feed like Chase) to a workspace
  2. Navigate to the company cards page
  3. Click "Assign card" on an unassigned card
  4. Complete the assignment flow
  5. Verify the card is assigned successfully without errors

Test 2:

Preconditions:

  • Workspace has an active commercial card feed
  • Credit cards are available to be assigned
  • Transactions exist on the card feed
  1. Assign a company credit card to a user via New Expensify
  2. Wait for transactions to import
  3. Observe the user’s expenses / unreported card transactions
  4. Verify Card transactions imported automatically after assignment
  5. Verify Transactions appear under the assigned user in New Expensify
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

// TODO: These must be filled out, or the issue title must include "[No QA]."

Same As Tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

CleanShot.2026-01-15.at.02.49.39.mp4
CleanShot.2026-01-15.at.03.15.54.mp4
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/hooks/useAssignCard.ts 87.17% <100.00%> (+87.17%) ⬆️
...workspace/companyCards/assignCard/CardNameStep.tsx 0.00% <ø> (ø)
...ce/companyCards/assignCard/InviteNewMemberStep.tsx 0.00% <0.00%> (ø)
src/libs/actions/CompanyCards.ts 0.00% <0.00%> (ø)
...mpanyCardsTable/WorkspaceCompanyCardsTableItem.tsx 0.00% <0.00%> (ø)
...space/companyCards/assignCard/ConfirmationStep.tsx 78.00% <33.33%> (+78.00%) ⬆️
...workspace/companyCards/assignCard/AssigneeStep.tsx 48.14% <0.00%> (+48.14%) ⬆️
...pace/companyCards/assignCard/CardSelectionStep.tsx 0.00% <0.00%> (ø)
.../companyCards/WorkspaceCompanyCardsTable/index.tsx 0.00% <0.00%> (ø)
src/libs/CardUtils.ts 72.23% <60.00%> (+1.36%) ⬆️
... and 19 files with indirect coverage changes

…ber encryption logic and update WorkspaceCompanyCardsTable to utilize it
… ConfirmationStep to use encryptedCardNumber correctly
@fedirjh fedirjh marked this pull request as ready for review January 15, 2026 03:31
@fedirjh fedirjh requested review from a team as code owners January 15, 2026 03:31
@melvin-bot melvin-bot bot requested review from ShridharGoel and trjExpensify and removed request for a team January 15, 2026 03:31
@melvin-bot
Copy link

melvin-bot bot commented Jan 15, 2026

@ShridharGoel Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot removed the request for review from a team January 15, 2026 03:31
@fedirjh fedirjh removed the request for review from ShridharGoel January 15, 2026 03:33
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b14bffd5f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b14bffd5f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chrispader
Copy link
Contributor

@fedirjh why are you removing the logic for failed company card assignments here?

This was mainly for displaying a pending failed card assignment for failed network requests. I think we still want to be able to show that pending action

@fedirjh
Copy link
Contributor Author

fedirjh commented Jan 17, 2026

BE shouldn't throw error "402 Missing cardName" ❌ (could related to BE validation or FE Card name validating string length instead of bytes [check Merchant field for reference])

@ikevin127 Is this bug caused by the change in this PR or has it already existed before?

@ikevin127
Copy link
Contributor

@ikevin127 Is this bug caused by the change in this PR or has it already existed before?

Not caused by a change in this PR, already exists on staging - it's BE related most likely.

@fedirjh
Copy link
Contributor Author

fedirjh commented Jan 17, 2026

Not caused by a change in this PR, already exists on staging - it's BE related most likely.

I think we should tackle it in a followup PR.

❌ Assignment During Feed Refresh

This should be fixed.

@ikevin127
Copy link
Contributor

❌ Assignment During Feed Refresh

This should be fixed.

@fedirjh Just checked again after latest commits and it's still happening, here's what I'm actually doing:

  • Right after clicking Assign card, as fast as possible press CMD+R to refresh page

What happens, upon refresh user sees 🔴 "Card assignment failed." and the optimistic row shows default name that was in the flow at assignment time -> but once error is cleared manually - the Card name is empty on the row while card remains assigned to the user.

The case where the Card name is empty depends on how fast after pressing Assign card you press refresh browser:

  • if you do it really fast / right-away then the Card name will empty when clearing error
  • if not done really fast then data seems to go through and Card name won't clear when clearing error
Screen.Recording.2026-01-16.at.17.35.44.mov

@fedirjh
Copy link
Contributor Author

fedirjh commented Jan 17, 2026

Right after clicking Assign card, as fast as possible press CMD+R to refresh page

I am not sure if I understand the bug correctly. I have updated the assignCard command to throw an error, and it's working as expected :

CleanShot.2026-01-17.at.03.04.26.mp4

if you do it really fast / right-away then the Card name will empty when clearing error

Also commands in dev runs in ms. I cannot beat that with my fingers 😄

Copy link
Contributor

@ikevin127 ikevin127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I posted videos as well - can't explain it more than I already did + videos, so if you think everything works as expected then I'm fine to move forward 👍

…nt logic in CompanyCards and WorkspaceCompanyCardsTable
@fedirjh
Copy link
Contributor Author

fedirjh commented Jan 17, 2026

I see the error, I think this is an edge case and not sure if this can be fixed, It seems the app aborts the first request to assign the card, but that request already reached the BE, Since that request is aborted, the app will try to run a new request which will fail because of the previous one already assigned the card. The problem is that the first request should return data about that assigned card, which includes the card name. I have pushed a fix to use the default name in case the card name is missing.

@ikevin127 Could you retest it?

@ikevin127
Copy link
Contributor

I retested, Card name is still not showing on the row in specific case when refreshed right away.

BE response when this happens:

{
    "code": 666,
    "jsonCode": 666,
    "type": "Expensify\\Libs\\Error\\ExpError",
    "UUID": "1d215fbc-6fd8-41fb-881c-b0fba808b1c7",
    "message": "This card has already been assigned to this member on a different feed.",
    "title": "Unable to assign card",
    "data": {
        "onyxData": [
            {
                "onyxMethod": "merge",
                "key": "assignCard",
                "value": {
                    "errors": {
                        "1768622681468262": "This card has already been assigned to this member on a different feed."
                    }
                }
            }
        ]
    },
    "htmlMessage": "",
    "onyxData": [
        {
            "onyxMethod": "merge",
            "key": "assignCard",
            "value": {
                "errors": {
                    "1768622681468262": "This card has already been assigned to this member on a different feed."
                }
            }
        }
    ],
    "requestID": "9bf2f84ee81bed3d-SJC"
}

Here are 2 videos with different cases:

  • first one is a user account that has first / last name set -> no Card name in the row, but shows in Card details RHP only visually - if clicked on the input doesn't have value
  • second one is a user account that doesnt have name set -> this completely clears Card name everywhere
Screen.Recording.2026-01-16.at.20.07.32.mov
Screen.Recording.2026-01-16.at.20.06.57.mov

I understand there's a BE sync issue - I just wanted to report it since I found it during manual testing and felt it was worth mentioning - if it's not in scope we're all good here - Approved 🟢

carlosmiceli
carlosmiceli previously approved these changes Jan 18, 2026
@carlosmiceli
Copy link
Contributor

carlosmiceli commented Jan 18, 2026

I think both remaining issues are out of scope of this PR, so approved. @tgolen @trjExpensify @joekaufmanexpensify feel free to approve/merge 👍

@trjExpensify
Copy link
Contributor

@joekaufmanexpensify is product on this: #79625 (review)

Copy link
Contributor

@joekaufmanexpensify joekaufmanexpensify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go from my perspective. @fedirjh there's an ESLint failing check, could you take a look at that?

@fedirjh
Copy link
Contributor Author

fedirjh commented Jan 20, 2026

@joekaufmanexpensify Should be good to merge.

@joekaufmanexpensify joekaufmanexpensify merged commit f151fd1 into Expensify:main Jan 20, 2026
28 of 29 checks passed
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@brianlee-expensify
Copy link
Contributor

brianlee-expensify commented Jan 20, 2026

@fedirjh nice to meet you! just wanted to ask two questions here:

  1. i saw the PR was just merged - any idea when this would get deployed to production?
  2. as i plan to reach out to affected customers en masse, would they need to manually update their cards in order to see the missing transactions appear moving forward?

@fedirjh fedirjh deleted the fix-invalid-encryptedCardNumber branch January 20, 2026 17:13
@fedirjh
Copy link
Contributor Author

fedirjh commented Jan 20, 2026

Hey @brianlee-expensify Nice to meet you too.

i saw the PR was just merged - any idea when this would get deployed to production?

@brianlee-expensify This will be shipped in the next prod deployment. You can subscribe to that in #80009

as i plan to reach out to affected customers en masse, would they need to manually update their cards in order to see the missing transactions appear moving forward?

Yes, they should unassign affected cards, then reassign them, So the fix can take effect.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/joekaufmanexpensify in version: 9.3.5-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.3.5-7 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants