Skip to content

Limit card fraud alert GBR and buttons to the cardholder - #102581

Merged
stitesExpensify merged 11 commits into
Expensify:mainfrom
youssef-lr:app-100123-card-fraud-gbr
Oct 6, 2026
Merged

stitesExpensify merged 11 commits into
Expensify:mainfrom
youssef-lr:app-100123-card-fraud-gbr

Conversation

@youssef-lr

@youssef-lr youssef-lr commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Fixes an issue where admins saw the green dot and the "Yes, I do" / "No, it wasn't me" buttons on a cardholder's fraud alert, and where both stayed after fraud was cleared on the card. The GBR also remained visible for the submitter even after the fraud was cleared.

Fixed Issues

$ #100123
PROPOSAL: N/A

Tests

Setup: web, sign in as a user with a workspace. Open your workspace chat and copy its reportID from the URL. In the console, set R = '<reportID>'.

  1. Add a fake flagged card and an unresolved alert:
    Onyx.merge('cardList', {999: {cardID: 999, bank: 'Expensify Card', state: 3, nameValuePairs: {possibleFraud: {fraudAlertReportID: Number(R)}}}});
    Onyx.merge(`reportActions_${R}`, {9990001: {reportActionID: '9990001', actionName: 'ACTIONABLECARDFRAUDALERT', created: '2026-09-29 12:00:00.000', originalMessage: {cardID: 999, maskedCardNumber: '****1234', triggerAmount: 5000, triggerMerchant: 'Test Shop', currency: 'USD'}}});
  2. Verify the workspace chat has a green dot in the LHN, Home shows "Review fraudulent charge", and the alert shows both buttons. Don't press them, the card is fake.
  3. Clear the fraud on the card: Onyx.merge('cardList', {999: {nameValuePairs: {possibleFraud: null}}})
  4. Verify the green dot, the Home tile, and the buttons disappear. The alert message stays.
  5. Simulate a non-cardholder (admin): rerun step 1, then Onyx.merge('cardList', {999: null})
  6. Verify no green dot and no buttons. The alert message stays.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests. Client-only change.

QA Steps

Same as tests.

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

Main
https://github.com/user-attachments/assets/f4705618-2828-440e-8e26-baf7bf58db19

This PR
https://github.com/user-attachments/assets/76880a16-c41e-42fc-9d53-74590c2f11d4

@youssef-lr youssef-lr self-assigned this Sep 29, 2026
@youssef-lr
youssef-lr marked this pull request as ready for review September 29, 2026 19:27
@youssef-lr
youssef-lr requested review from a team as code owners September 29, 2026 19:27
@melvin-bot
melvin-bot Bot requested review from dylanexpensify and situchan and removed request for a team September 29, 2026 19:27
@melvin-bot

melvin-bot Bot commented Sep 29, 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 September 29, 2026 19:27
@youssef-lr youssef-lr changed the title Limit card fraud alert green dot and buttons to the cardholder with l… Limit card fraud alert GBR and buttons to the cardholder Sep 29, 2026
@youssef-lr

Copy link
Copy Markdown
Contributor Author

bump @situchan

@situchan

situchan commented Oct 1, 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.
  • 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).
  • 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
before.fix.mov
after.fix.mov

dylanexpensify
dylanexpensify previously approved these changes Oct 2, 2026

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

Looks good from a product perspective 👍

@youssef-lr

Copy link
Copy Markdown
Contributor Author

bump @situchan

@youssef-lr
youssef-lr force-pushed the app-100123-card-fraud-gbr branch from 3d640a2 to e483b26 Compare October 5, 2026 16:54
Comment thread src/libs/ReportUtils.ts Resolved
@situchan

situchan commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Please pull main to fix job 6

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The fix looks correct, and I found no blocking issues. The green dot, the Home tile, and the buttons now all depend on the same check: the current user's card has live possibleFraud that points at this report. The derived value also refreshes the old report when fraud clears, because it keeps the previous fraudAlertReportIDs. Card changes unrelated to fraud fall through to the existing early return, so they don't trigger a full scan.

Minor points, none blocking:

  1. The Debug page loses the fraud reason. src/libs/DebugUtils.ts:1603 and requiresAttentionFromCurrentUser don't pass cardList. Before this PR they read report actions from global state; now they never return HAS_UNRESOLVED_CARD_FRAUD_ALERT. So the Debug page can show "no GBR" while the LHN shows one. Consider passing cardList in DebugUtils.
  2. There's a redundant check. In isCardFraudAlertUnresolved, isCardWithPotentialFraud(card) is always true once possibleFraud.fraudAlertReportID exists. It's harmless, so you can keep it for intent or drop it.
  3. The button check uses the report being displayed. FraudAlertContent.tsx:38 compares against the reportID prop, which is the report on screen. Comparing against action.reportID instead would keep the buttons if the alert ever renders outside its own report.

CI: test (job 6) fails on the current head in SelectFeaturesEmptyTagGroupTest and AgentZeroStatusContextTest. This PR doesn't touch either one. The other failures are only the checklist and approval checks.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor

Regression check

I found one likely regression and one edge case worth fixing. The LHN, focus mode, To-do, and Home tile all get the new check, the removed exports have no other users, and the order of attention reasons is unchanged.

1. Stale green dots survive the upgrade (confirmed in code). REPORT_ATTRIBUTES is saved to disk. On app start, the first compute has no sourceValues. If the card list has no fraud IDs, cardChangedReportKeys is empty and the compute returns the stored value at reportAttributes.ts:436. This keeps both bugs the PR fixes until something else changes the report:

  • An admin who already has the dot on an employee's fraud chat keeps it.
  • A cardholder whose fraud was cleared before the update keeps it.

Fix: on the first compute (previousFraudAlertReportIDs === undefined), also recompute the reports where currentValue.reports[id].requiresAttention is true. That's a small set.

2. The dot and the buttons match cards differently (possible). The dot fires when any card's fraudAlertReportID matches the report (ReportUtils.ts:4629). The buttons only check the card in the alert's originalMessage.cardID (FraudAlertContent.tsx:34-38). If possibleFraud is ever on a different card than the alert's cardID, the cardholder gets a dot with no buttons and can't clear it. For example, this can happen after a card is reissued or when fraud is flagged at the domain level. Fix: in isCardFraudAlertUnresolved, also require that the unresolved action's cardID matches card.cardID.

Lower-risk notes
  • Backend timing: the dot and buttons now need possibleFraud.fraudAlertReportID in the card list, not just the alert action. The Home tile already depended on this before the PR, so the risk is low. Please confirm the backend sends the card update together with the alert.
  • Debug page: DebugUtils.ts:1603 doesn't pass cardList, so the Debug page no longer shows the fraud reason. The tab unread badge and search options also skip cardList, but they never show this dot, so users see no change.
  • Extra work: the comment at reportAttributes.ts:489 says card changes are treated like policy changes. But the card keys never go into nameSkipKeys at line 496, so report names are recomputed anyway. While a card has live fraud, every card list change recomputes those reports.
  • Archived reports: they no longer show the fraud dot. The alert is already hidden on reports the user can't write to, so this is fine.

view run

@situchan

situchan commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

The provided test case works well but please check above. The edge cases are non blockers though

@situchan

situchan commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Looks like job 4 failure is related

@youssef-lr youssef-lr changed the title Limit card fraud alert GBR and buttons to the cardholder [WIP] Limit card fraud alert GBR and buttons to the cardholder Oct 6, 2026
@youssef-lr

Copy link
Copy Markdown
Contributor Author

Added WIP, will see if I can simplify this PR.

@youssef-lr youssef-lr changed the title [WIP] Limit card fraud alert GBR and buttons to the cardholder Limit card fraud alert GBR and buttons to the cardholder Oct 6, 2026
@youssef-lr
youssef-lr requested a review from situchan October 6, 2026 19:14
@youssef-lr

Copy link
Copy Markdown
Contributor Author

Ready again @situchan

@situchan

situchan commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review (head d8b708c9)

The new commits look correct, and I found no blocking issues. All required CI checks pass. The only failing check is Check independent approval.

What changed since my last review:

  • The fraud alert lookup now matches on the alert's cardID.
  • The check now runs after the archived-report early return.
  • On app start, the derived value rechecks stored green dots that target a fraud alert.

The app-start recheck is safe. Derived values compute only after every dependency has loaded (OnyxDerived/index.ts:87), so reportActions is available when the stored dots are seeded.

Minor points:

  1. Old unresolved alerts for the same card. This bug left alerts unresolved after fraud was cleared. If the same card is flagged again in the same chat, two things happen:

    Consider limiting both to the newest alert, unless the backend resolves every alert for the card at once.

  2. Debug page. This is still open from my last review. DebugUtils.ts:1607 and requiresAttentionFromCurrentUser don't pass cardList. They can never report HAS_UNRESOLVED_CARD_FRAUD_ALERT, so the Debug page won't explain a fraud green dot.


view run

@melvin-bot

melvin-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

We did not find an internal engineer to review this PR, trying to assign a random engineer to #100123 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 stitesExpensify October 6, 2026 19:37
@MelvinBot

Copy link
Copy Markdown
Contributor

Regression check (head d8b708c9)

I found one low-severity regression. A full recompute can keep a stale name on the fraud alert report.

What happens: Card-changed reports are added to nameSkipKeys at reportAttributes.ts:516 even when needsFullRecompute is true. The policy name-skip is guarded against this case; the card one isn't. So when a locale, currency list, Concierge, or intro change runs in the same compute as a card change, every report gets a fresh name except the fraud alert report. The first compute after the app starts also adds card keys.

Evidence: I ran a local test with a stored "Stale name". On a full recompute for a locale change or a currency list load, report 222 got the fresh name. Fraud report 111 kept "Stale name".

Fix: Add card keys to nameSkipKeys only on incremental updates:

...(useIncrementalUpdates ? cardChangedReportKeys.filter((key) => !nameRelevantPolicyReportKeys.has(key)) : [])

With that change, my test and all of reportAttributesTest.ts pass (45/45).

Checked with no regression found
  • LHN, focus mode, and unread indicator: These read requiresAttention from the derived value, which now gets cardList.
  • Card changes unrelated to fraud: They hit the existing "no updates" early return, so they don't cause a full scan.
  • Resolve buttons: resolveFraudAlert sets resolution and clears possibleFraud optimistically, and failureData restores both. So the buttons hide on press and come back on failure.
  • Sign-out and sign-in: resetForClear drops the derived value and calls onReset, so fraud state from the old session doesn't carry over.
  • cardID match: OriginalMessageCardFraudAlert.cardID is required, and FraudAlertContent already looks up the card by that ID.
  • Callers that don't pass cardList: DebugUtils, requiresAttentionFromCurrentUser (option-list fallback), and useOptimisticNextStep never return the fraud reason now. Only the Debug page shows this (raised earlier). Expense reports don't hold fraud alerts.
  • CI: All required checks pass. Only Check independent approval fails.

view run

@youssef-lr

Copy link
Copy Markdown
Contributor Author

Yeah I’ll push a fix now

@stitesExpensify
stitesExpensify merged commit f016f85 into Expensify:main Oct 6, 2026
34 of 35 checks passed
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

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

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

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

👀 View the workflow run that generated this build 👀

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

@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/stitesExpensify in version: 9.5.4-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This is a bug fix that stops showing fraud alert buttons, the green dot, and the Home task to admins and after fraud is cleared, which is what users already expect, and no existing article describes the old behavior.


view run

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

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