Skip to content

Add Assign new cards option for direct card feeds#84313

Merged
carlosmiceli merged 33 commits intoExpensify:mainfrom
fedirjh:sync-card-feed-on-demand
Mar 17, 2026
Merged

Add Assign new cards option for direct card feeds#84313
carlosmiceli merged 33 commits intoExpensify:mainfrom
fedirjh:sync-card-feed-on-demand

Conversation

@fedirjh
Copy link
Contributor

@fedirjh fedirjh commented Mar 5, 2026

Explanation of Change

Direct card feeds cache their accountList at initial connection. When banks issue new cards, they don't appear in NewDot's assignment UI. This PR adds an "Assign new cards" menu item in the feed settings page (only for direct feeds) that triggers the existing OAuth/Plaid reconnection flow to refresh the card list.

Changes:

  • Add "Assign new cards" MenuItem in WorkspaceCompanyCardsSettingsPage, conditionally rendered for direct feeds only
  • Create a dedicated RefreshCardFeedConnectionPage route and component that reuses BankConnection/PlaidConnectionStep
  • Add isRefreshFlow prop to BankConnection so it always opens bank auth and dismisses the modal after re-auth (instead of proceeding to assign card steps)
  • Add route infrastructure: SCREENS, ROUTES, navigation types, linking config, modal stack navigator

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/594594
$ #79383
PROPOSAL:

Tests

  1. Navigate to a workspace with a direct (OAuth) card feed
  2. Go to Settings for that feed
  3. Verify "Assign new cards" menu item appears with Sync icon and description "Get the latest cards to assign from your bank"
  4. Tap "Assign new cards" → verify bank auth opens
  5. Complete re-auth → verify modal dismisses
  6. Navigate to a workspace with a commercial card feed → Settings → verify "Assign new cards" does NOT appear
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline
  2. Navigate to feed settings → tap "Assign new cards"
  3. Verify the offline blocking view is shown
  4. Go back online → verify the flow resumes

QA Steps

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

  1. Navigate to a workspace with a direct card feed → Settings
  2. Verify "Assign new cards" appears only for direct feeds (OAuth/Plaid)
  3. Tap "Assign new cards" and complete re-auth
  4. Verify modal dismisses after re-auth
  5. Verify no errors in JS console
  • 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 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-03-05.at.21.24.01.mp4
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

fedirjh added 2 commits March 5, 2026 17:18
Direct card feeds cache their accountList at initial connection, so newly
issued cards don't appear in the assignment UI. This adds a menu item in
the feed settings page (only for direct/OAuth/Plaid feeds) that triggers
the existing bank reconnection flow to refresh the card list.
Create a dedicated RefreshCardFeedConnectionPage that reuses
BankConnection/PlaidConnectionStep with an isRefreshFlow prop.
When isRefreshFlow is true, BankConnection always opens the bank
auth and dismisses the modal after re-auth instead of proceeding
to the assign card flow.
@melvin-bot
Copy link

melvin-bot bot commented Mar 5, 2026

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

fedirjh added 3 commits March 5, 2026 21:16
Enhance user experience by adding success messages for refreshed bank connections in both English and Spanish translations. Update the RefreshCardFeedConnectionPage and related components to handle the new success state, ensuring proper navigation and user feedback upon successful re-authentication.
…on component

Update the BankConnection component to ensure proper navigation when a feed connection is broken. The logic for handling broken connections has been streamlined to avoid redundancy, improving code clarity and maintainability. Additionally, adjust header titles to reflect the correct context based on the refresh connection flow.
@fedirjh
Copy link
Contributor Author

fedirjh commented Mar 5, 2026

@MelvinBot Please generateTranslations for this PR.

@MelvinBot
Copy link
Contributor

All translations for this PR are already present in both en.ts and es.ts. Here's a summary:

Key English Spanish
assignNewCards Assign new cards Asignar nuevas tarjetas
assignNewCardsDescription Get the latest cards to assign from your bank Obtén las últimas tarjetas de tu banco para asignar
refreshConnectionSuccess Connection refreshed Conexión actualizada
refreshConnectionSuccessDescription Your bank connection has been re-authenticated successfully. You can now assign new cards. La conexión con tu banco ha sido reautenticada exitosamente. Ahora puedes asignar nuevas tarjetas.

The Spanish translations look accurate. No missing translations were found — all translate() calls in the changed files reference keys that exist in both language files.

@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/ROUTES.ts 15.83% <100.00%> (+0.07%) ⬆️
src/SCREENS.ts 100.00% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 75.00% <ø> (ø)
src/pages/workspace/withPolicy.tsx 100.00% <ø> (ø)
...gation/AppNavigator/ModalStackNavigators/index.tsx 7.30% <0.00%> (-0.01%) ⬇️
...ace/companyCards/RefreshCardFeedConnectionPage.tsx 87.50% <87.50%> (ø)
.../BankConnection/openBankConnection/index.native.ts 0.00% <0.00%> (ø)
...kspace/companyCards/addNew/PlaidConnectionStep.tsx 0.00% <0.00%> (ø)
...s/workspace/companyCards/addNew/AddNewCardPage.tsx 0.00% <0.00%> (ø)
...companyCards/WorkspaceCompanyCardsSettingsPage.tsx 0.00% <0.00%> (ø)
... and 4 more
... and 19 files with indirect coverage changes

fedirjh added 4 commits March 5, 2026 21:51
Introduce a new test file for the RefreshCardFeedConnection component, implementing various test cases to ensure correct rendering and functionality based on different connection steps. The tests cover loading states, bank connection rendering, and plaid connection handling, enhancing overall test coverage and reliability.
@fedirjh
Copy link
Contributor Author

fedirjh commented Mar 5, 2026

@carlosmiceli Could you please trigger the translation script for this PR: #84313 (comment)

@fedirjh fedirjh requested a review from carlosmiceli March 5, 2026 23:29
@fedirjh
Copy link
Contributor Author

fedirjh commented Mar 5, 2026

@MelvinBot Review this PR

@MelvinBot
Copy link
Contributor

Code Review — PR #84313

Overall the PR is well-structured and follows established patterns (mirrors BrokenCardFeedConnectionPage). Navigation infrastructure, translations, and tests are solid. I found one logic concern and one minor inconsistency worth discussing.


1. Split isFeedConnectionBroken check in BankConnection (both platforms)

In both BankConnection/index.tsx and BankConnection/index.native.tsx, the original single if (isFeedConnectionBroken) block was split into two separate blocks with the refresh flow check inserted between them:

// NEW CODE (both files):
if (isFeedConnectionBroken) {
    updateBrokenConnection();
}
if (isRefreshConnectionFlow && onRefreshComplete) {
    onRefreshComplete();
    return;
}
if (isFeedConnectionBroken) {
    Navigation.goBack(...); // or Navigation.closeRHPFlow() on web
    return;
}

The concern: When isFeedConnectionBroken === true AND isRefreshConnectionFlow === true, updateBrokenConnection() fires, then onRefreshComplete() is called and returns early. The user sees "Connection refreshed successfully" even though isFeedConnectionBroken was true in that render cycle (the Onyx update from updateBrokenConnection hasn't propagated yet).

This might be intentional — the user just re-authenticated, so treating it as a success makes sense. But the original code treated broken connections as an atomic bail-out. If this is intentional, consider restructuring for clarity:

if (isRefreshConnectionFlow && onRefreshComplete) {
    if (isFeedConnectionBroken) {
        updateBrokenConnection();
    }
    onRefreshComplete();
    return;
}
if (isFeedConnectionBroken) {
    updateBrokenConnection();
    Navigation.goBack(...);
    return;
}

This makes the intent explicit rather than relying on fall-through between two identical condition checks.


2. Missing header title update in native BankConnection

BankConnection/index.tsx (web) updates the header title for the refresh flow:

const headerTitleAddCards = !backTo
    ? translate(isRefreshConnectionFlow ? 'workspace.moreFeatures.companyCards.assignNewCards' : 'workspace.companyCards.addCards')
    : undefined;

But BankConnection/index.native.tsx still has the original:

const headerTitleAddCards = !backTo ? translate('workspace.companyCards.addCards') : undefined;

Since the native BankConnection renders its own header (not wrapped by RefreshCardFeedConnectionPage's header in the BANK_CONNECTION case), this means native users would see "Add cards" instead of "Assign new cards" during the refresh flow.


Everything else looks good

  • Navigation infrastructure (ROUTES, SCREENS, types, linkingConfig, ModalStackNavigators, withPolicy) — all correct and consistent. The new screen correctly omits the legacy backTo param.
  • RefreshCardFeedConnectionPage — properly follows the BrokenCardFeedConnectionPage pattern. Cleanup effect, HOC usage, and step-based rendering are all correct.
  • Plaid flowPlaidConnectionStep transitions to BankConnection via Onyx step change, so it doesn't need onRefreshComplete directly. This is correct.
  • openBankConnectionFlow — mirrors the existing pattern in WorkspaceCompanyCardsTableHeaderButtons. isDirectFeed, getPlaidInstitutionId, getPlaidCountry, and Navigation.setNavigationActionToMicrotaskQueue are all used correctly.
  • Translations — all 9 language files updated with appropriate translations.
  • Tests — comprehensive test coverage for step rendering, success view, and cleanup.
  • isPlaid/url refactoring in index.tsx — semantically equivalent to the original, cleaner structure.

Updated the logic for handling broken feed connections in the BankConnection component. The update ensures that the `updateBrokenConnection` function is called appropriately during both the assign card flow and the refresh connection flow, improving the reliability of the connection handling. Additionally, modified the header title logic to reflect the current flow more accurately.
@fedirjh fedirjh requested a review from a team March 6, 2026 00:02
@fedirjh fedirjh marked this pull request as ready for review March 6, 2026 00:02
@fedirjh fedirjh requested review from a team as code owners March 6, 2026 00:02
@melvin-bot melvin-bot bot requested review from heyjennahay and hungvu193 and removed request for a team March 6, 2026 00:03
@melvin-bot
Copy link

melvin-bot bot commented Mar 6, 2026

@hungvu193 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 March 6, 2026 00:03
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: 1329a71f3a

ℹ️ 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".

@fedirjh
Copy link
Contributor Author

fedirjh commented Mar 12, 2026

@joekaufmanexpensify @carlosmiceli I have updated the logic in 3cf060b . This will enforce refreshing the feed regardless of the auth expiration time.

@carlosmiceli
Copy link
Contributor

@joekaufmanexpensify @carlosmiceli I have updated the logic in 3cf060b . This will enforce refreshing the feed regardless of the auth expiration time.

Great! That's actually a much better solution, I agree, consistent behavior. Thanks Fedi!

@joekaufmanexpensify
Copy link
Contributor

@joekaufmanexpensify @carlosmiceli I have updated the logic in 3cf060b . This will enforce refreshing the feed regardless of the auth expiration time.

Nice! Just to make sure I am following, that means:

  1. If your auth hasn't expired, tapping the button will try to get new cards.
  2. if it has expired, you'll be prompted to auth, after which we will also try to get new cards.

Is that right @fedirjh ?

@fedirjh
Copy link
Contributor Author

fedirjh commented Mar 12, 2026

  1. If your auth hasn't expired, tapping the button will try to get new cards.

@joekaufmanexpensify No. You'll be prompted to auth as well, after which we will also try to get new cards.

@joekaufmanexpensify
Copy link
Contributor

@fedirjh I see. Is that because once we've pulled the list, auth is required to get a new list from the bank, even if the token hasn't expired for assigning cards we already have?

@carlosmiceli
Copy link
Contributor

@joekaufmanexpensify I think the UX that Fedi implemented is correct: just because you're authenticated, we can't fetch any new cards after the authentication flow is complete. If you're authenticated from minute 0 to 15, if there would be a new card to assign in the feed from minute 5, we can't see it. Each fetch needs the authentication to happen again.

@fedirjh wanna ask Melvin to fix tests and/or merge main?

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.

Sounds good, change is fine from my perspective then 👍

@carlosmiceli carlosmiceli merged commit 926a075 into Expensify:main Mar 17, 2026
33 checks passed
@fedirjh fedirjh deleted the sync-card-feed-on-demand branch March 17, 2026 18:29
@github-actions
Copy link
Contributor

🚧 @carlosmiceli has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/carlosmiceli in version: 9.3.40-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/carlosmiceli in version: 9.3.40-0 🚀

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

@jponikarchuk
Copy link

Deploy Blocker #85676 was identified to be related to this PR.

@lanitochka17
Copy link

Deploy Blocker ##85693 was identified to be related to this PR.

@carlosmiceli
Copy link
Contributor

@fedirjh we had to revert this PR because it caused some blockers that couldn't be quickly fixed. Mainly, we should reimplement this feature but include:

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/carlosmiceli in version: 9.3.41-0 🚀

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

Bundle Size Analysis (Sentry):

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.

8 participants