Repository navigation
Scan Receipt UX/perf improvements - #83470
Conversation
Freeze camera preview immediately after capture and add pronounced shutter flash effect for all captures (not just multi-scan mode) to provide clear visual feedback.
Move directory creation from capture critical path to camera initialization to reduce capture latency by ~40ms.
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.
|
Use useCameraFormat to select a known photo format, then pass it to the NavigationAwareCamera component so the camera captures at a predictable aspect ratio.
Compute aspect ratio from the selected format and apply it to the camera view so the preview matches the photo output exactly. Falls back to flex:1 if no format is available.
Since the viewfinder now matches the camera format aspect ratio, cropping is no longer needed. This eliminates ~520ms of image processing (reading dimensions + expo-image-manipulator) from the shutter-to-confirmation flow.
Remove cropImageToAspectRatio, ImageObject, LayoutRectangle imports and viewfinderLayout ref that are no longer needed since the native capture path no longer crops.
The format filter only matched aspect ratio, so it could pick a low-resolution 4:3 format causing a blurry preview. Add videoResolution and photoResolution 'max' filters to prefer the highest quality format.
Add getCameraViewfinderStyle() to StyleUtils for the dynamic viewfinder aspect ratio. Replace {backgroundColor: theme.appBG} with StyleUtils.getBackgroundColorStyle(). Both fix inline style violations per STYLING.md.
Restore 0.4 opacity / 10ms+50ms timing instead of the more pronounced 1.0 / 50ms+150ms version.
|
🚧 @marcaaron has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
@eVoloshchak 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] |
|
|
||
| // Pre-create upload directory to avoid latency during capture | ||
| const path = getReceiptsUploadFolderPath(); | ||
| ReactNativeBlobUtil.fs.isDir(path).then((isDir) => { |
There was a problem hiding this comment.
❌ CONSISTENCY-6 (docs)
The ReactNativeBlobUtil.fs.isDir(path) promise is missing a .catch() handler. If the filesystem check fails, the error becomes an unhandled promise rejection and the upload directory will not be pre-created. The old code in capturePhoto had a .catch() for this same isDir call.
Add a .catch() to handle the isDir failure:
ReactNativeBlobUtil.fs.isDir(path).then((isDir) => {
if (isDir) {
return;
}
ReactNativeBlobUtil.fs.mkdir(path).catch((error: string) => {
Log.warn('Error creating the receipts upload directory', error);
});
}).catch((error: string) => {
Log.warn('Error checking if the upload directory exists', error);
});Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
@marcaaron Can you confirm that we will fix this issue in the next PR? |
|
@MarioExpensify 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] |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 957a28564c
ℹ️ 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".
I think we do a follow up for this. It's an edge case. |
|
Created issue for us to look into later #83949 |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c8824cf9d
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (isMultiScanEnabled) { | ||
| setDidCapturePhoto(false); | ||
| isCapturingPhoto.current = false; |
There was a problem hiding this comment.
Keep freeze state active for multi-scan captures
didCapturePhoto is set to true when takePhoto() resolves, but in the multi-scan branch it is synchronously reset to false in the same callback. With React Native/React's automatic batching, the camera can skip rendering an intermediate true state, so forceInactive={... || didCapturePhoto} never takes effect and the preview does not visibly freeze for multi-scan shots. This regresses the intended UX feedback in the exact mode this change targets.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The lack of a freeze in multi-scan is intentional as the camera should stay active between shots. This feedback is wrong to say there was a regression as we just implemented this. I tested to be sure and everything looks fine IMO.
|
This is ready for internal review. |
|
🚧 @marcaaron has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
The callGetOptionData helper in SidebarUtilsTest.ts was missing the required currentUserLogin property, causing the TypeScript check to fail. This was a pre-existing issue on main introduced in the recent merge of PR #83470. Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
|
🚀 Deployed to staging by https://github.com/marcaaron in version: 9.3.31-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.3.31-12 🚀
|

Explanation of Change
Improves the receipt scan camera UX and reduces capture latency:
useCameraFormatto select a 4:3 photo format and constrain the viewfinder to match that format's aspect ratio. Since the preview and photo now share the same aspect ratio,cropImageToAspectRatiois no longer needed on the native capture path, eliminating ~520ms ofImageSize.getSize()+expo-image-manipulatorprocessing per capture. The crop codepath is unchanged for web and odometer image capture.Note: The original
SPAN_TAKE_PHOTOtelemetry span from this PR was superseded bySPAN_RECEIPT_CAPTUREfrom #83729 during merge conflict resolution. Receipt capture telemetry is now covered by that span.Fixed Issues
$ #83469
Tests
Offline tests
N/A - camera capture is a local operation
QA Steps
Regression: Viewfinder matches saved photo (#66652)
Platforms: iOS, Android
Regression: Landscape capture (#71644)
Platforms: iOS, Android
Regression: Multi-scan stability (#68516)
Platforms: Android (primary), iOS
Regression: Odometer image capture
Platforms: iOS, Android
Regression: Web scan unchanged
Platforms: Chrome, Safari
Regression: Gallery pick and receipt replacement
Platforms: iOS, Android
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
N/A changes affect mobile - issue does not exist on mWeb
iOS: Native
ScreenRecording_02-25-2026.10-22-36_1.MP4
iOS: mWeb Safari
N/A changes affect mobile - issue does not exist on mWeb
MacOS: Chrome / Safari
N/A changes affect mobile - issue does not exist on web