Skip to content

Open the broken card feed from the wallet company cards link - #98021

Merged
madmax330 merged 8 commits into
Expensify:mainfrom
marufsharifi:fix/company-cards-link-opens-broken-feed
Aug 18, 2026
Merged

Open the broken card feed from the wallet company cards link#98021
madmax330 merged 8 commits into
Expensify:mainfrom
marufsharifi:fix/company-cards-link-opens-broken-feed

Conversation

@marufsharifi

@marufsharifi marufsharifi commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

The Wallet company cards link and Home page broken company card connection CTA now select the card’s own broken company-card feed with updateSelectedFeed before navigating to the Workspace Company Cards page, so admins land on the broken feed instead of the last manually selected feed.

Fixed Issues

$ #91300
PROPOSAL:

Tests

Precondition:

  • Logged in to a walletConnectionStatus beta account.

Flow 1: Wallet link

  1. Go to the workspace Company cards page and select the healthy feed.
  2. Go to Account > Wallet > Cards.
  3. Verify the card on the broken feed shows Inactive and Please fix this connection in company cards.
  4. Click the company cards link.
  5. Verify the Company cards page opens on the broken feed, not the healthy one.

Flow 2: Home CTA

  1. Go to the workspace Company cards page and select the healthy feed, so it becomes the last selected feed
  2. Go to Home.
  3. Verify the time-sensitive row for the broken company card connection is shown.
  4. Click Fix.
  5. Verify the Company cards page opens on the broken feed, not the healthy one.
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

// TODO: These must be filled out, 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

Flow 1: Wallet link

Screen.Recording.2026-08-07.at.5.27.13.PM.mov

Flow 2: Home CTA

Screen.Recording.2026-08-11.at.2.37.31.PM.mov
Android: mWeb Chrome

Flow 1: Wallet link

Screen_Recording_20260807_173107_Chrome.mp4

Flow 2: Home CTA

Screen_Recording_20260811_143956_Chrome.mp4
iOS: Native

Flow 1: Wallet link

Screen.Recording.2026-08-07.at.5.53.08.PM.mov

Flow 2: Home CTA

Screen.Recording.2026-08-11.at.2.53.58.PM.mov
iOS: mWeb Safari

Flow 1: Wallet link

Screen.Recording.2026-08-07.at.5.54.29.PM.mov

Flow 2: Home CTA

Screen.Recording.2026-08-11.at.2.55.21.PM.mov
MacOS: Chrome / Safari

Flow 1: Wallet link

Screen.Recording.2026-08-07.at.4.53.41.PM.mov

Flow 2: Home CTA

Screen.Recording.2026-08-11.at.2.42.06.PM.mov

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

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/libs/CardUtils.ts 84.50% <100.00%> (+0.07%) ⬆️
...ensitiveSection/items/FixCompanyCardConnection.tsx 2.50% <0.00%> (-0.14%) ⬇️
src/pages/settings/Wallet/PaymentMethodList.tsx 0.00% <0.00%> (ø)
... and 11 files with indirect coverage changes

@marufsharifi
marufsharifi marked this pull request as ready for review August 7, 2026 15:53
@marufsharifi
marufsharifi requested review from a team as code owners August 7, 2026 15:53
@melvin-bot
melvin-bot Bot requested review from heyjennahay and mkhutornyi and removed request for a team August 7, 2026 15:53
@melvin-bot

melvin-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

@mkhutornyi 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 August 7, 2026 15:53
Comment thread src/ROUTES.ts Outdated
@mkhutornyi

Copy link
Copy Markdown
Contributor

@marufsharifi please check & address #98021 (comment)

@marufsharifi

Copy link
Copy Markdown
Contributor Author

@marufsharifi please check & address #98021 (comment)

@mkhutornyi, addressed please check once again.

@marufsharifi

Copy link
Copy Markdown
Contributor Author

@mkhutornyi, Gentle bump. thanks.

@mkhutornyi

mkhutornyi commented Aug 10, 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 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 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 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 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.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The switch from the ?feed= query param to persisting lastSelectedFeed via updateSelectedFeed before navigating (per mkhutornyi's suggestion) looks correct and clean. The feed key produced by getCompanyCardFeedWithDomainIDForCard is the same feed#domainID shape that getCompanyFeeds keys on, so getSelectedFeed validates it and lands on the broken feed rather than falling back to the default. One actionable item and two nits below.

🟡 The PR description is now stale

The description still describes the old query-param approach:

The link now carries the card's own feed in the route, so clicking it — or opening the copied link in a new tab — lands on the broken feed.

Neither is true anymore. The current implementation navigates to the plain route (PaymentMethodList.tsx:371) and persists the feed to Onyx via updateSelectedFeed (:368-369) — nothing is carried in the URL. And as established earlier in this thread, the copy-link / open-in-new-tab flow isn't reachable at all (this renders as a TextLink, not a real anchor). Please update the description so it matches the Onyx-persistence approach and drop the new-tab claim.

🔵 Nits (optional)

  • Redundant guard: In getCompanyCardFeedWithDomainIDForCard, the leading !card.fundID is already covered by isPersonalCard(card) (which returns true when !card?.fundID or fundID === '0'). Harmless, and arguably clarifies intent — leave it if you prefer explicitness.
  • Overlap with existing helper: ${getCompanyCardFeed(card.bank)}#${card.fundID} is value-equivalent to getCardFeedWithDomainID(card.bank, card.fundID) (already imported in the file), since card.bank contains no separator. The new helper still earns its keep via the personal/Expensify-card guards and the CompanyCardFeedWithDomainID return type, so keeping it is fine — just noting the overlap.
Things I checked that are fine
  • Merge-before-navigate ordering is safe. updateSelectedFeed does an async Onyx.merge, but WorkspaceCompanyCardsPage reads lastSelectedFeed reactively through useCompanyCards/useOnyx, so it re-renders onto the correct feed once the merge lands (and once that policy's feeds finish loading). No race that leaves the user on the wrong feed.
  • Guard scoping. companyCardFeedForCard is only consumed inside the shouldUseCompanyCardsLink branch, which is company-card-only, so the undefined-for-personal/Expensify return can never be misused.
  • Test coverage. CardUtilsTest.ts covers the happy path plus the personal-card and Expensify-card undefined cases. (No coverage of the onLinkPress navigation itself, which is expected — it's not easily unit-testable.)

This is an automated review — treat it as a second set of eyes, not a substitute for a human reviewer.

@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: ed55ee8a79

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

Comment thread src/pages/settings/Wallet/PaymentMethodList.tsx
@MelvinBot

Copy link
Copy Markdown
Contributor

Regression check

No blocking regressions found. The RBR/red-dot refactor is behavior-preserving, and the new updateSelectedFeed call is correctly scoped to admin company cards on the Wallet page. One intended-but-worth-noting behavior change and one theoretical edge case below.

🟡 By-design behavior change (not a bug)

Clicking the "fix connection in company cards" link now overwrites the policy's remembered feed (lastSelectedFeed) as a side effect, at PaymentMethodList.tsx:368-371. So if an admin had feed A selected on the Company cards page, then clicks fix-connection for a card on feed B, a later independent visit to Company cards opens B instead of A. This is the point of the PR and is consistent with every other updateSelectedFeed caller (feed selector, bank-connection flow), so it's fine — just flagging it's a persisted per-policy change, not scoped to this navigation.

🔵 Theoretical edge (very unlikely, worth a glance)

The feed-collection keys build the domainID numerically (Number(...)), but getCompanyCardFeedWithDomainIDForCard interpolates card.fundID verbatim. For any canonical numeric fundID these match (`${12345}` === `${"12345"}`). They'd only diverge for a non-canonical string (leading zeros like "007", whitespace, decimals). If they diverge, getSelectedFeed fails its availableFeeds[key] check and gracefully falls back to the default feed — i.e. the fix silently no-ops, never a broken/blank page. No action needed unless fundID can ever be non-canonical.

What I verified (all no-regression)
  • RBR refactor is identical. getCardFeedWithDomainID always returns a #-containing (truthy) string, so feedNameWithDomainID is truthy exactly when card.fundID was truthy before (including the '0' case). The else if branch fires under the same conditions. PaymentMethodList.tsx:295-303
  • Side-effect scope. PaymentMethodList renders at 4 sites; only the two WalletPage sites pass shouldShowConnectionStatus, and the link path additionally requires !isPersonalCardStatus && isAdminForCardPolicy && policyID. The two invoice/bank-account sites are inert. Personal cards use onActionPress (unchanged); Expensify cards get undefined from the new helper and are guarded out.
  • Feed-key equality. getCompanyCardFeed(card.bank) is a no-op for a bank name (no # to split), so the new helper produces the same bank#fundID string the rest of the codebase uses to match cards to feeds (CardFeedUtils.ts). Key matches availableFeeds.
  • Graceful fallback. updateSelectedFeed does no validation, but getSelectedFeed validates against availableFeeds and falls back to the default feed for any unknown key (CardUtils.ts:1015-1020) — no bad-state path.

Web smoke test: Account > Wallet > Cards rendered cleanly with all controls and no error boundary. The test account has no connected cards, so the actual card-row connection-status / red-dot rendering (the PR's target) couldn't be exercised — that path still needs a manual pass on a walletConnectionStatus beta account with a broken feed, per the PR's own test steps.

Wallet page top with Bank accounts section

Wallet page top with Bank accounts section

Full Wallet page including complete Cards section

Full Wallet page including complete Cards section

Automated regression scan — a second set of eyes, not a substitute for the manual broken-feed test.

@mkhutornyi

Copy link
Copy Markdown
Contributor

Actually, we're fixing the bug happening in production (Home page).
So we should treat this as separate bug (not regression/followup of #93852)

Screen.Recording.2026-08-10.at.3.30.14.PM.mov

@marufsharifi let's fix this case as same root cause

Comment thread src/libs/CardUtils.ts Outdated
@marufsharifi

Copy link
Copy Markdown
Contributor Author

@mkhutornyi addressed your feedback, and fixed the Home CTA case too. Also updated the PR test steps and recordings. Could you check once again?

@quinthar quinthar removed the #quality label Aug 13, 2026
@mkhutornyi

Copy link
Copy Markdown
Contributor

Please fix conflict

@melvin-bot
melvin-bot Bot requested a review from Gonals August 13, 2026 15:42
@marufsharifi

Copy link
Copy Markdown
Contributor Author

@Gonals conflict resolved, thanks

@madmax330
madmax330 merged commit da5be7b into Expensify:main Aug 18, 2026
35 of 36 checks passed
@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.56-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help-site changes required

I reviewed this PR against the help articles in App/docs/articles and no documentation updates are needed, so I did not open a draft docs PR.

Why: This is a navigation-behavior refinement, not a change to any documented feature, flow, label, or concept. Clicking the Wallet company cards link (Please fix this connection in company cards) or the Fix CTA in the Time Sensitive section on Home now selects the card's own broken feed via updateSelectedFeed before opening the Company cards page, so admins land on the broken feed instead of the last manually selected feed. No new UI, tab, setting, or button label was added, and the specific "which feed opens" detail isn't described in any help article.

Articles checked
  • Fix-a-Broken-Company-Card-Feed-Connection.md — the closest match. Its documented steps (Home Time Sensitive notification → Workspaces > [Workspace name] > Company cards → locate the feed with the red dot → select the error message) remain accurate. It doesn't reference the Wallet company cards link or which feed the CTA lands on, so nothing became stale.
  • Assign-Company-Cards.md, Configure-Company-Card-Settings.md, and the Wallet articles (Reimbursement-Payment-Methods.md, Pay-Expenses.md) — none describe this link/CTA target-feed behavior.

If you'd still like a help article to explicitly call out that these shortcuts open the broken feed directly, let me know and I'll draft one.

@marufsharifi — no linked help-site PR was created because no docs changes are required. If you disagree, reply with the detail you'd like documented and I'll open a draft PR.

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