Skip to content

Keep showing a broken card's status past the 90-day grace period - #100277

Merged
puneetlath merged 38 commits into
Expensify:mainfrom
marufsharifi:fix/broken-card-status-hidden-past-90-days
Oct 6, 2026
Merged

puneetlath merged 38 commits into
Expensify:mainfrom
marufsharifi:fix/broken-card-status-hidden-past-90-days

Conversation

@marufsharifi

@marufsharifi marufsharifi commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The 90-day grace period was being applied to the card's status, not just to the prompting. A card broken for longer than that read as Active while the old raw backend error still rendered underneath it, so the badge and the error contradicted each other.

The status now stays truthful: a long-broken card shows Inactive with our own message, and the raw backend error is replaced by it. The grace period still does its job, so the error no longer lights the Account button or the Wallet row. Company cards now follow the same rule personal cards already did.

Fixed Issues

$ #100197
PROPOSAL:

Tests

Precondition: an account with a card whose last successful sync is more than 90 days old and that has a connection error.

  1. Open Settings > Wallet > Cards.
  2. Verify the card shows Inactive with the message to fix the connection, and no raw backend error.
  3. Verify the Account button and the Wallet row show no red dot.
  4. Verify the Workspaces button, the workspace, and its Company cards row show no red dot.
  • 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.
    • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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
Screenshot 2026-09-03 at 9 35 35 PM
Android: mWeb Chrome
Screenshot_20260903_212058_Chrome
iOS: Native
Screenshot 2026-09-03 at 9 51 11 PM
iOS: mWeb Safari
Screenshot 2026-09-03 at 9 39 10 PM
MacOS: Chrome / Safari
Screenshot 2026-09-03 at 9 18 37 PM

@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/CONST/index.ts 95.86% <100.00%> (+0.03%) ⬆️
...nyCardsTable/getShouldShowBrokenConnectionError.ts 100.00% <100.00%> (ø)
src/hooks/useCardFeedErrors.ts 100.00% <ø> (ø)
src/libs/CardFeedUtils.ts 81.22% <100.00%> (+2.13%) ⬆️
src/libs/CardUtils.ts 87.61% <100.00%> (+0.06%) ⬆️
src/libs/PolicyUtils/index.ts 89.82% <100.00%> (+0.05%) ⬆️
...libs/actions/OnyxDerived/configs/cardFeedErrors.ts 97.93% <100.00%> (+0.06%) ⬆️
src/libs/actions/PaymentMethods.ts 37.81% <100.00%> (+3.62%) ⬆️
...ort/actionContents/CardBrokenConnectionContent.tsx 100.00% <100.00%> (ø)
.../pages/settings/Wallet/PersonalCardDetailsPage.tsx 0.00% <0.00%> (ø)
... and 3 more
... and 9 files with indirect coverage changes

@melvin-bot

melvin-bot Bot commented Sep 4, 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 request for a team September 4, 2026 09:50

@dylanexpensify dylanexpensify left a comment

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.

@joekaufmanexpensify also assigning you given it's tied to the card errors issue you're on. Looks fine to me, but want your expertise in the area to ensure all good 🙇‍♂️

@marufsharifi

Copy link
Copy Markdown
Contributor Author

@mkhutornyi, I’ve addressed all the feedback. All yours—thanks!

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

This comment has been minimized.

@marufsharifi

Copy link
Copy Markdown
Contributor Author

@mkhutornyi, Gentle bump. thanks.

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

BUG: not showing option to fix all broken personal cards older than 90 days

I tested in an account that has four broken personal cards older than 90 days. Two show the option to fix them, two do not. The two that do are scraping 438. Two that do not are scraping 434. Compare these cards in new Expensify versus Expensify Classic below.

image image

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

BUG: not showing inactive badge for all broken company cards

I tested another account that has three different broken company cards. Feedback:

  • Two of them show the inactive badge and direct the user to go to the company cards page. Third says active incorrectly. The two with the inactive badge are scraping 438. The one with the active badge is scraping 434.
  • This user is an admin. We shouldn't ask them to ask an admin to fix it if it's something they can do themselves.

We are correctly showing the option to fix the connection on the company cards page for all three cards, though.

Adhoc

image

Staging

image

@mkhutornyi

Copy link
Copy Markdown

Are both comments addressed? Please pull main

@marufsharifi

Copy link
Copy Markdown
Contributor Author

@mkhutornyi Fixed both cases. Could you check once again, the action failure seems not related to our PR. Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

This comment has been minimized.

@MelvinBot

MelvinBot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Code review — two issues worth fixing before merge, plus two smaller ones to confirm.

1. hasErrorNewerThanLastScrape compares a local-time date against UTC timestamps

src/libs/CardUtils.ts:1507-1537 parses lastScrape with parse(..., 'yyyy-MM-dd HH:mm:ss', new Date()), which date-fns resolves in the device's time zone. But lastScrape is UTC — the App's own convention appends Z before parsing DB datetimes (DateUtils.ts:106) and writes them with toISOString() (DateUtils.ts:393). The error keys it's compared against are UTC epoch microseconds (DateUtils.ts:388).

So lastScrapeMicroseconds is off by the device's UTC offset. On any device east of UTC (Europe, India, Asia, Australia) it lands before the real scrape time, the server's connection error reads as "newer", shouldShowCardErrorMessages flips true, and the raw backend error renders under the Inactive badge again — the exact contradiction this PR removes. West of UTC it errs the other way and hides a genuine fresh error recorded within a few hours of the scrape.

Fix: parse the DB format as UTC, keeping the new Date() path for values that already carry an offset.

Why the unit test can't catch this, and the suggested change

tests/unit/CardUtilsTest.ts:4485-4488 builds the expected value with new Date('2025-10-05T11:00:00').getTime(). That string has no Z, so it's parsed as local time too — the same interpretation as the code under test. The test is self-consistent and blind to the offset at any TZ.

const DB_DATETIME = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
const lastScrapeDate = DB_DATETIME.test(card.lastScrape) ? new Date(`${card.lastScrape.replace(' ', 'T')}Z`) : new Date(card.lastScrape);

A regression test that keys the error with a real UTC microsecond value (Date.parse('2025-10-05T11:00:00Z') * 1000) fails today under TZ=Asia/Kolkata and passes under TZ=UTC.

This assumes the server keys the connection error at (or near) scrape time in microseconds, which is what the comparison and the tests are built on. If it actually uses a non-numeric key like connectionError, Number(key) is NaN and the comparison never fires at all — in which case the whole timestamp branch is dead for its stated purpose. Worth confirming which it is.

I verified this by reading the code, not by running it — Bash was restricted in this run, so I couldn't execute the test files.

2. The company-card grace period silences every error, not just connection errors

src/libs/actions/PaymentMethods.ts:446-450 returns false for any card whose last sync is past the threshold, and cardsWithErrors holds cards with any error. A company card that last synced 100 days ago and then fails an unassignment shows the error on its wallet row but lights no red dot on Account or Wallet — the opposite of the reasoning that motivated hasErrorNewerThanLastScrape in PaymentMethodList. Suggested:

if (CardUtils.isLastScrapePastDismissThreshold(card) && !CardUtils.hasErrorNewerThanLastScrape(card)) {
    return false;
}

The personal-card branch just above has the same gap (pre-existing), so applying the same guard to both keeps them consistent.

3. A never-synced card now shows the raw error again

With no lastScrape, hasErrorNewerThanLastScrape returns true (CardUtils.ts:1532-1534). Such a card is inside the grace period, so it gets the connection message and the backend error underneath it. Before this PR the error was suppressed. If a card broken on its first sync is realistic here, returning false when there's nothing to compare against is the safer default.

4. Confirm the row red dot is meant to diverge

PaymentMethodList.tsx:305 still uses isCardConnectionBroken for the personal-card brickRoadIndicator. A 434 card whose errors have been dismissed therefore reads Inactive with a fix prompt but carries no red dot on its own row. That may well be intended under the grace-period design — flagging it because the two predicates now disagree at one call site.


Everything else reads well: pulling the date parsing into parseCardLastScrape removes the duplication, hasCardConnectionIssue keying off lastScrapeResult rather than dismissible errors is the right call and is covered by a test, and the useAccountIndicatorChecks tests cover both sides of the grace period. The branch is also still behind main, which mkhutornyi asked for earlier.


view run · no recording available

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

ℹ️ 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/libs/CardUtils.ts Resolved
Comment thread src/libs/actions/PaymentMethods.ts Resolved
@marufsharifi

Copy link
Copy Markdown
Contributor Author
  1. Company cards banner appears for a 434 feed and reconnecting never clears it

This is the case I asked you about earlier. Could you check whether reconnecting clears a 434? I can't confirm it without a real bank connection.

@mkhutornyi addressed the other feedback, just one open item I can't settle on my own — do you have access to check this? Thanks

  1. A feed whose only problem is a 434 card now shows a banner that reconnecting doesn't clear

Confirmed the client side: updateBrokenConnection only runs when isFeedConnectionBroken, and only re-syncs cardsWithBrokenFeedConnection — both exclude 434. So reconnecting never touches that card.

What I can't tell is whether reconnecting clears a 434 at all. Re-syncing those cards would also set them to 200 optimistically, so the card would read as healthy until the server replied and sent it back to 434.

@mkhutornyi

Copy link
Copy Markdown
  1. Company cards banner appears for a 434 feed and reconnecting never clears it

This is the case I asked you about earlier. Could you check whether reconnecting clears a 434? I can't confirm it without a real bank connection.

Same. I'd rather leave this as edge case

@mkhutornyi

Copy link
Copy Markdown
  1. Wallet row goes silent about a company card's own error
  2. Account button and Settings > Wallet row lose their red dot

They're the same thing — the connection message replaces the card's errors, and past 90 days they're hidden everywhere.

I tried fixing it twice. By error age, which your mocks caught in #100277 (comment), and by error key, which didn't hold because the server doesn't use one key consistently. Both errors sit in the same field with nothing to tell them apart, so it's hide both or show both. Showing both brings back the raw error this PR removes.

The branch hides both. Is that okay with you?

ok with me. At least I won't block on this. Seems back and forth

@melvin-bot

melvin-bot Bot commented Oct 1, 2026

Copy link
Copy Markdown

We did not find an internal engineer to review this PR, trying to assign a random engineer to #100197 as well as to this PR... Please reach out for help on Slack if no one gets assigned!

@melvin-bot
melvin-bot Bot requested a review from puneetlath October 1, 2026 09:44
puneetlath
puneetlath previously approved these changes Oct 1, 2026
@puneetlath

Copy link
Copy Markdown
Contributor

@marufsharifi the author checklist check is failing.

@marufsharifi

Copy link
Copy Markdown
Contributor Author

@puneetlath, the checklist has been updated. All yours now—thanks!

@marufsharifi

Copy link
Copy Markdown
Contributor Author

@puneetlath, friendly bump. Thanks!

@marufsharifi

Copy link
Copy Markdown
Contributor Author

Conflicts resolved.

@puneetlath
puneetlath merged commit 42daf9e into Expensify:main Oct 6, 2026
35 of 36 checks passed
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Oct 6, 2026

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

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #100277.

Android 🤖 iOS 🍎
❌ FAILED ❌ https://ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com/rock-artifacts/ad-hoc/rock-ios-device-AdHoc-42daf9e-596acd4-f5157ce76bace87653ba8ed66c574726bcf6e0f1/index.html
The QR code can't be generated, because the Android build failed iOS
Web 🕸️
https://100277.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

@OSBotify OSBotify mentioned this pull request Oct 6, 2026
100 tasks done
@OSBotify

OSBotify commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/puneetlath in version: 9.5.4-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update is needed. This is a bug fix: a card that has been broken for more than 90 days now shows Inactive instead of a contradictory Active, which is what users would already expect.

Articles checked

The articles that describe the 90-day behavior are still accurate after this change:

No article says a broken card shows Active. The remaining changes, such as the 434 status handling and the workspace lookup for the Company cards link, are edge cases or implementation details.


view run

@IuliiaHerets

Copy link
Copy Markdown

Hi @marufsharifi. Can you please share which account we can use for preconduction?

image

cc @dylanexpensify @puneetlath @joekaufmanexpensify @mkhutornyi

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

@IuliiaHerets I think this one needs to be internal QA. I will take care of it in a bit 👍

@joekaufmanexpensify

Copy link
Copy Markdown
Contributor

Passed QA, checked off on list

@OSBotify

OSBotify commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 9.5.4-3 🚀

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

Bundle Size Analysis (Sentry):

*/
function getShouldShowBrokenConnectionError(feedName: CompanyCardFeedWithDomainID, feedErrors: CardFeedErrorState | undefined): boolean {
return (!!feedErrors?.isFeedConnectionBroken && isDirectFeed(feedName)) || !!feedErrors?.hasFeedErrors;
const hasConnectionToFix = !!feedErrors?.isFeedConnectionBroken || !!feedErrors?.hasFeedConnectionIssue;

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.

This PR caused the regression in #105932 (fixed in #106104).

Adding hasFeedConnectionIssue to the banner condition means a single 434 card now shows "Card feed connection is broken" for the whole feed, even though the other cards still sync. #84803 had excluded 434 from feed-level warnings.

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