Skip to content

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

Draft
MelvinBot wants to merge 1 commit into
mainfrom
claude-plaidReconnectExistingFeed
Draft

Reuse existing Plaid feed on reconnect instead of creating a duplicate#96349
MelvinBot wants to merge 1 commit into
mainfrom
claude-plaidReconnectExistingFeed

Conversation

@MelvinBot

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%> (ø)
... and 8 files with indirect coverage changes

@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.

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.

2 participants