Skip to content

Reuse existing Plaid feed on reconnect instead of creating a duplicate - #96349

Merged
madmax330 merged 3 commits into
mainfrom
claude-plaidReconnectExistingFeed
Jul 28, 2026
Merged

Reuse existing Plaid feed on reconnect instead of creating a duplicate#96349
madmax330 merged 3 commits into
mainfrom
claude-plaidReconnectExistingFeed

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

The NewDot "fix broken connection" flow for Plaid company-card feeds created a duplicate feed instead of repairing the existing one. On reconnect, PlaidConnectionStep derived a fresh feed from the Plaid Link metadata — a bare, unprefixed institution ID (e.g. ins_123456) — and passed that to importPlaidAccounts, discarding the existing feed prop it already held.

Server-side, ImportPlaidAccounts decides repair-vs-create purely on whether the incoming feed starts with the plaid. prefix. A bare institution ID misses the prefix, so the server took its create-new-feed branch and minted a duplicate.

This change makes the reconnect branch pass the existing feed (which keeps its plaid. prefix and originating #domainID) to importPlaidAccounts instead of the freshly-derived bare institution ID. importPlaidAccounts runs getCompanyCardFeed(feed), which strips only the #domainID suffix and preserves the plaid. prefix — so the server now sees a prefixed feed and repairs the existing feed in place rather than creating a second one. The new public token still refreshes the credentials.

It also forwards the feed's originating domainID (parsed from the CompanyCardFeedWithDomainID) to the server as a new domainAccountID param when repairing an existing feed. This is the Plaid analog of the Chase reconnect fix (#95214): for a Classic domain-level feed surfaced into a workspace via "preferred workspace", it lets the server refresh credentials on the domain the broken cards actually belong to instead of the synthetic workspace-policy domain. The paired server change lives in Web-Expensify PR https://github.com/Expensify/Web-Expensify/pull/54605.

When no feed is being repaired (adding a new feed), behavior is unchanged.

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/653959
PROPOSAL: https://github.com/Expensify/Expensify/issues/653959#issuecomment-4935721846

Tests

// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review". At minimum, verify that reconnecting a broken Plaid company-card feed repairs the existing feed instead of creating a duplicate.

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review", or the issue title must include "[No QA]."

  • 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 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 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)
  • 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)
  • 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.
  • 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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

…licate

Co-authored-by: Maxence Coulibaly <madmax330@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team July 16, 2026 19:56
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
...kspace/companyCards/addNew/PlaidConnectionStep.tsx 0.00% <ø> (ø)
src/libs/actions/Plaid.ts 0.00% <0.00%> (ø)
...space/companyCards/BankConnection/index.native.tsx 0.00% <0.00%> (ø)

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I looked into the failing checks — there's nothing to fix in code. Every automated check passes (typecheck, ESLint, all 8 test jobs, Bun tests, baseline/branch-perf-tests, all builds, Storybook, spellcheck, etc.).

The one red check is PR Author Checklist / checklist, which failed with:

You completed 0 out of 38 checklist items with 38 unfinished items

That's a human-only check — it verifies the author has ticked the boxes in the PR Author Checklist and filled out the Tests / QA Steps sections. Right now the PR body still has the boilerplate placeholders:

  • The ### Tests and ### QA Steps sections still contain the // TODO: **The human co-author** must fill out... notes
  • None of the 38 ### PR Author Checklist boxes are checked

I intentionally don't fill these out on an author's behalf. To turn this check green, madmax330 needs to complete the checklist and testing sections in the PR description, then re-run the check. Once that's done, all checks will be passing.

@madmax330

Copy link
Copy Markdown
Contributor

@MelvinBot can you merge main?

…ExistingFeed

Co-authored-by: Maxence Coulibaly <madmax330@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 Merged the latest main into claude-plaidReconnectExistingFeed and pushed. The merge was clean — no conflicts.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

There's no code fix to push here — all real CI checks are green.

The only failing check is PR Author Checklist / checklist, and that isn't a code failure. It fails by design because the author checklist boxes are unticked and the Tests / QA Steps sections still have the // TODO placeholders. Those must be completed by the human co-author (madmax330), not by me. Once you check the boxes and fill in the Tests/QA steps, that check will pass.

Check status

Passing: Bun tests, test (job 1-8), typecheck, ESLint, Oxfmt, React Compiler, Storybook, spellcheck, unused-styles, knip, build (Debug/Development), CLA, validate, verifySignedCommits.

Failing: PR Author Checklist / checklist — expected; requires the author to complete the checklist and Tests/QA sections.

Still running (non-blocking): baseline-perf-tests, branch-perf-tests.

@madmax330
madmax330 marked this pull request as ready for review July 27, 2026 17:49
@madmax330
madmax330 requested a review from a team as a code owner July 27, 2026 17:49
@melvin-bot
melvin-bot Bot requested review from heyjennahay and situchan and removed request for a team July 27, 2026 17:49
@melvin-bot

melvin-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

@situchan 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 July 27, 2026 17:49
@madmax330
madmax330 requested review from fedirjh and removed request for situchan July 27, 2026 17:49
@madmax330

Copy link
Copy Markdown
Contributor

@fedirjh it's the same as this for plaid: #95214 (comment)

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

Copy link
Copy Markdown

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: 476b143e1a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

importPlaidAccounts(
publicToken,
plaidConnectedFeed,
feed,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid queueing a second bare-feed import

When RefreshCardFeedConnectionPage refreshes an expired Plaid feed, this corrected import is immediately followed by setAssignCardStepAndData, which mounts BankConnection; both its web and native effects then call useImportPlaidAccounts(). That hook reads the bare plaidConnectedFeed stored as institutionId, so it queues another ImportPlaidAccounts request without the plaid. prefix or domainAccountID. Because this command has no conflict resolver, the second request can still take the create-new-feed branch and undo the intended duplicate-feed fix; preserve the existing feed in the state consumed by that hook or skip the second import for reconnects.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@MelvinBot can you address this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in a6893be — the concern was real, but only on native. Pushed a fix.

What was happening (native only): After the repair importPlaidAccounts call, PlaidConnectionStep runs setAssignCardStepAndData({cardToAssign: {institutionId: plaidConnectedFeed /* bare */}}, BANK_CONNECTION) and RefreshCardFeedConnectionPage mounts BankConnection with the feed prop. In the native effect the guard was if (feed && !isFeedExpired) — so while the repair is still in flight and the feed still reads as expired, that block is skipped and execution falls through to if (isPlaid) { onImportPlaidAccounts(); }, which reads the bare institutionId (no plaid. prefix, no domainAccountID) and queues a second ImportPlaidAccounts. With no conflict resolver, that second request can take the server's create-new-feed branch and undo the fix.

Why web was already safe: the web effect uses if (feed) { if (!isFeedExpired) {…} if (isPlaid) { return; } }, so a still-expired Plaid feed returns early and never fires a second import.

Fix: aligned the native effect with the web one so a Plaid reconnect returns instead of re-importing:

src/pages/workspace/companyCards/BankConnection/index.native.tsx:122-139

The add-new-feed path (feed undefined) is unchanged and still imports via onImportPlaidAccounts(); OAuth reconnects (feed present, not Plaid) are also unchanged.

Checks run locally
  • ESLint (scripts/lint.sh on the changed file) — pass
  • React Compiler compliance (check, both Babel + OXC) — compiled
  • tests/unit/RefreshCardFeedConnectionPageTest.tsx — 10/10 pass
  • typecheck-tsgo — no new errors in the changed file (the reported errors are pre-existing, in unrelated files); full tsc OOM'd at the 8 GB ceiling in this environment, not a type error.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

There's nothing for me to fix here — all 36 real CI checks pass (build, tests, typecheck, ESLint, Oxfmt, spellcheck, perf, etc.).

The only failing check is PR Reviewer Checklist / checklist (run), which fails because it's a human-completed checklist — the reviewer's checkboxes in the review comment aren't all ticked yet. It's not a CI or code failure, so there's no branch change I can push to resolve it.

To clear it: the reviewer needs to complete the PR Reviewer Checklist (check all boxes in their review). The review check is still pending (the automated review is in progress), and the PR is BLOCKED on these checklist/review items rather than on any test or build failure.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The only failing check is PR Reviewer Checklist / checklist, which failed with:

No PR Reviewer Checklist was found

This isn't a code or CI failure — it's not something I can fix by pushing a commit. That check scans the PR comments for a completed reviewer checklist and stays red until a human reviewer posts one. Every other check on this PR is green (tests, ESLint, typecheck, Oxfmt, build, Storybook, perf, etc.).

To clear it: a reviewer needs to complete the PR Reviewer Checklist on this PR (it's normally posted by the assigned C+/reviewer). Once that checklist comment exists, this check will pass on the next run.

No code changes are warranted here.

@MelvinBot
MelvinBot requested a review from a team as a code owner July 27, 2026 20:19
@melvin-bot
melvin-bot Bot requested a review from ChavdaSachin July 27, 2026 20:19
@melvin-bot

melvin-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

@ChavdaSachin 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 July 27, 2026 20:19
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Nothing has changed since my previous comment. The only failing check is still PR Reviewer Checklist / checklist, failing with No PR Reviewer Checklist was found.

This is not a code/CI failure and re-running or pushing a commit won't clear it. It fails because no completed reviewer checklist has been posted on this PR yet. A reviewer (the assigned C+) needs to copy in and complete the PR Reviewer Checklist — once that comment exists, the check will pass on its next run. All other checks are green.

@madmax330
madmax330 removed the request for review from ChavdaSachin July 28, 2026 11:33
@madmax330

Copy link
Copy Markdown
Contributor

@fedirjh can you review when you get a chance?

@fedirjh

fedirjh commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • 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 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)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
CleanShot.2026-07-28.at.16.30.45.mp4
Screenshot 2026-07-28 at 4 32 28 PM Screenshot 2026-07-28 at 4 32 39 PM Screenshot 2026-07-28 at 4 32 46 PM

@madmax330
madmax330 merged commit 49c0d8e into main Jul 28, 2026
42 of 43 checks passed
@madmax330
madmax330 deleted the claude-plaidReconnectExistingFeed branch July 28, 2026 20:26
@OSBotify

Copy link
Copy Markdown
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.

@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/madmax330 in version: 9.4.46-0 🚀

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

@izarutskaya

Copy link
Copy Markdown

@madmax330 @mountiny Do we need any QA for this?

@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 I reviewed the changes in this PR against the help site files under docs/articles, applying HELPSITE_NAMING_CONVENTIONS.md, HELP_AUTHORING_GUIDELINES.md, and TEMPLATE.md.

No help site changes are required.

Why: This PR is an internal bug fix. It changes how the NewDot "fix broken connection" flow builds the request it sends to the server (passing the existing prefixed feed + originating domainAccountID instead of a bare institution ID) so reconnecting a broken Plaid company-card feed repairs the existing feed instead of minting a duplicate. There is no change to any user-facing UI, tab name, setting label, button, or documented flow — the user still fixes a broken feed the same way.

The relevant article — Fix a Broken Company Card Feed Connection — already documents the intended behavior this fix restores:

When a company card connection is fixed, the card feed reconnects to your bank and the red dot error message disappears. New transactions begin importing again. Any missing transactions during downtime will import automatically.

The pre-fix duplicate-feed behavior was a bug, never documented, so the article is already accurate and needs no update. Accordingly, I did not create a draft docs PR.

@madmax330, if you believe there's a user-facing aspect here worth documenting (e.g. guidance specific to Plaid feed reconnects), let me know and I'll draft the article changes.

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.

6 participants