Skip to content

fix: show scan error instead of populating $0 amount when scan fails - #96772

Open
x-dev90 wants to merge 4 commits into
Expensify:mainfrom
x-dev90:fix/scan-show-error-instead-of-zero-amount
Open

fix: show scan error instead of populating $0 amount when scan fails#96772
x-dev90 wants to merge 4 commits into
Expensify:mainfrom
x-dev90:fix/scan-show-error-instead-of-zero-amount

Conversation

@x-dev90

@x-dev90 x-dev90 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR fixes failed SmartScan amount handling by distinguishing the SmartScan placeholder 0 from a user-entered $0.00.

When SmartScan fails without detecting an amount, the Amount row now renders empty and shows the missing amount error instead of displaying $0.00. Once the user manually enters 0, the app treats it as a valid amount and clears the error.

The same failed-scan placeholder handling is shared across the expense details view, split/confirmation amount display, and the amount edit submit flow so the behavior stays consistent.

Fixed Issues

$ #94494
PROPOSAL: #94494 (comment)

Tests

Flow 1: Workspace failed scan expense

  1. Sign in to New Expensify.
  2. Create a workspace.
  3. Open the workspace chat.
  4. Create a scan expense with a receipt/image that will fail SmartScan.
  5. Wait until the scan fails.
  6. Open the expense details.
  7. Verify the Amount field is empty instead of showing $0.00.
  8. Verify the Amount field shows the missing amount error.
  9. Open the Amount field.
  10. Enter 0 and save.
  11. Verify the Amount field shows $0.00.
  12. Verify the missing amount error is cleared.

Flow 2: Split expense failed scan

  1. Start a group chat.
  2. Split an expense using scan and upload an image that will fail SmartScan.
  3. Wait until the scan fails.
  4. Open the split expense details.
  5. Verify the Amount field is empty instead of showing $0.00.
  6. Verify the Amount field shows the missing amount error.
  • Verify that no errors appear in the JS console

Offline tests

N/A

QA Steps

Same as Tests.

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

Screen_Recording_20260724_005653_New.Expensify.Dev.mp4

Flow:2

Screen_Recording_20260724_005952_New.Expensify.Dev.mp4
Android: mWeb Chrome

Flow:1

Screen_Recording_20260724_002037_Chrome.mp4

Flow:2

Screen_Recording_20260724_010057_Chrome.mp4
iOS: Native

Flow:1

Screen.Recording.2026-07-24.at.12.35.40.AM.mp4

Flow:2

Screen.Recording.2026-07-24.at.12.40.00.AM.mp4
iOS: mWeb Safari

Flow:1

Screen.Recording.2026-07-24.at.12.40.54.AM.mp4

Flow:2

Screen.Recording.2026-07-24.at.12.42.25.AM.mp4
MacOS: Chrome / Safari

Flow:1

flow1.mov

Flow:2

Screen.Recording.2026-07-23.at.11.58.33.PM.mov

@codecov

codecov Bot commented Jul 22, 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/IOUAmountSubmission.ts 86.77% <100.00%> (+0.07%) ⬆️
src/libs/TransactionPreviewUtils.ts 85.97% <100.00%> (+0.12%) ⬆️
src/libs/TransactionUtils/index.ts 90.90% <100.00%> (+0.05%) ⬆️
...estConfirmationList/hooks/useConfirmationAmount.ts 90.90% <50.00%> (-4.10%) ⬇️
...c/components/ReportActionItem/MoneyRequestView.tsx 74.37% <80.00%> (+0.06%) ⬆️
... and 8 files with indirect coverage changes

@x-dev90
x-dev90 marked this pull request as ready for review July 23, 2026 21:06
@x-dev90
x-dev90 requested review from a team as code owners July 23, 2026 21:06
@melvin-bot
melvin-bot Bot requested a review from Ollyws July 23, 2026 21:06
@melvin-bot

melvin-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

@Ollyws 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 requested review from heyjennahay and removed request for a team July 23, 2026 21:06

@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: 8c91229118

ℹ️ 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/IOUAmountSubmission.ts Outdated
Comment thread src/libs/IOUAmountSubmission.ts Outdated
@x-dev90

x-dev90 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@Ollyws Could you please check this case and confirm if it is expected?

I compared the backend responses for saving 0 vs saving 1 on the failed SmartScan expense.

Case 1: Saving 0

When I save 0, the Amount row shows EUR 0.00, but the receipt-level SmartScan message still says:
(Receipt scanning failed — missing merchant, date, and amount. Enter details manually.)

The backend response returns a confirmed zero amount:

"modifiedAmount": 0,
"modifiedCurrency": "EUR"

but it still keeps the failed SmartScan missing-fields state:

"iouRequestType": "scan",
"receipt.state": "SCANFAILED",
"smartscanFailed.missingFields": ["merchant", "date", "amount"]

At this point, amount is already confirmed as 0, and the date is already filled, so the message should not still say date and amount are missing.

Screenshot 2026-07-24 at 11 40 40 AM

Case 2: Saving 1

When I save 1, the backend response changes the transaction to a manually edited amount:

"iouRequestType": "manual",
"modifiedAmount": -100,
"modifiedCurrency": "EUR"

and transactionViolations no longer contains smartscanFailed; it only returns receiptNotSmartScanned. Because of that, the receipt-level missing-fields message is cleared correctly.

Screenshot 2026-07-24 at 11 38 28 AM

So the confirmed-zero case is still handled differently from a normal amount edit. I think after the user manually confirms 0, the backend should treat it like the 1 case, or at least remove the fixed fields from smartscanFailed.missingFields, leaving only the fields that are still actually missing.

thanks!

cc @arosiclair

@arosiclair

Copy link
Copy Markdown
Contributor

So the confirmed-zero case is still handled differently from a normal amount edit. I think after the user manually confirms 0, the backend should treat it like the 1 case, or at least remove the fixed fields from smartscanFailed.missingFields, leaving only the fields that are still actually missing.

@dukenv0307 is this change do-able?

@dukenv0307

Copy link
Copy Markdown
Contributor

I've raised a BE PR to fix the issue above ^

@x-dev90

x-dev90 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@dukenv0307, has the BE pr merged? thanks

@dukenv0307

Copy link
Copy Markdown
Contributor

Yes, it's deployed to prod

@x-dev90

x-dev90 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@Ollyws Could you please check this and review when you get a chance? Thanks!

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.

3 participants