From 999dd46538d07546bd0365b27d6e55ee1397e310 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 08:47:31 -1000 Subject: [PATCH 01/15] Improve camera capture UX with freeze and enhanced shutter feedback 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. --- .../step/IOURequestStepScan/index.native.tsx | 24 +++++++++++-------- .../step/IOURequestStepScan/useReceiptScan.ts | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index d5c404c938ac..76cfbf26acd8 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -97,6 +97,9 @@ function IOURequestStepScan({ const cameraInitSpanStarted = useRef(false); const cameraInitialized = useRef(false); + // Ref for double-tap protection (doesn't trigger re-render) + const isCapturingPhoto = useRef(false); + // Start camera init span when permission is granted and camera is ready useEffect(() => { if (cameraInitSpanStarted.current || cameraPermissionStatus !== RESULTS.GRANTED || device == null) { @@ -200,6 +203,7 @@ function IOURequestStepScan({ useFocusEffect( useCallback(() => { setDidCapturePhoto(false); + isCapturingPhoto.current = false; const refreshCameraPermissionStatus = () => { CameraPermission?.getCameraPermissionStatus?.() .then(setCameraPermissionStatus) @@ -322,16 +326,13 @@ function IOURequestStepScan({ return; } - if (didCapturePhoto) { + if (isCapturingPhoto.current) { maybeCancelShutterSpan(); return; } - if (isMultiScanEnabled) { - showBlink(); - } - - setDidCapturePhoto(true); + isCapturingPhoto.current = true; + showBlink(); const path = getReceiptsUploadFolderPath(); @@ -357,6 +358,9 @@ function IOURequestStepScan({ path, }) .then((photo: PhotoFile) => { + // Freeze camera preview now that photo is captured + setDidCapturePhoto(true); + // Store the receipt on the transaction object in Onyx const transaction = isMultiScanEnabled && initialTransaction?.receipt?.source @@ -388,6 +392,7 @@ function IOURequestStepScan({ if (isMultiScanEnabled) { setDidCapturePhoto(false); + isCapturingPhoto.current = false; return; } @@ -396,7 +401,7 @@ function IOURequestStepScan({ ); }) .catch((error: string) => { - setDidCapturePhoto(false); + isCapturingPhoto.current = false; maybeCancelShutterSpan(); showCameraAlert(); Log.warn('Error taking photo', error); @@ -405,7 +410,6 @@ function IOURequestStepScan({ // eslint-disable-next-line react-hooks/exhaustive-deps -- askForPermissions is not needed }, [ cameraPermissionStatus, - didCapturePhoto, isMultiScanEnabled, translate, showBlink, @@ -490,13 +494,13 @@ function IOURequestStepScan({ photo cameraTabIndex={1} onLayout={(e) => (viewfinderLayout.current = e.nativeEvent.layout)} - forceInactive={isAttachmentPickerActive} + forceInactive={isAttachmentPickerActive || didCapturePhoto} onInitialized={handleCameraInitialized} /> diff --git a/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts b/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts index fe3bc75857ac..033b02bc14ef 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts +++ b/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts @@ -117,8 +117,8 @@ function useReceiptScan({ function showBlink() { blinkOpacity.set( - withTiming(0.4, {duration: 10}, () => { - blinkOpacity.set(withTiming(0, {duration: 50})); + withTiming(1, {duration: 50}, () => { + blinkOpacity.set(withTiming(0, {duration: 150})); }), ); HapticFeedback.press(); From beddf86c0d985789becf573d9595e21fbca87b37 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 08:53:07 -1000 Subject: [PATCH 02/15] Pre-create upload directory on camera init Move directory creation from capture critical path to camera initialization to reduce capture latency by ~40ms. --- .../step/IOURequestStepScan/index.native.tsx | 125 +++++++++--------- 1 file changed, 59 insertions(+), 66 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 76cfbf26acd8..e8aa08d9ccd8 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -147,6 +147,17 @@ function IOURequestStepScan({ endSpan(CONST.TELEMETRY.SPAN_CAMERA_INIT); } endSpan(CONST.TELEMETRY.SPAN_OPEN_CREATE_EXPENSE); + + // Pre-create upload directory to avoid latency during capture + const path = getReceiptsUploadFolderPath(); + 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); + }); + }); }, []); const askForPermissions = useCallback(() => { @@ -336,76 +347,58 @@ function IOURequestStepScan({ const path = getReceiptsUploadFolderPath(); - ReactNativeBlobUtil.fs - .isDir(path) - .then((isDir) => { - if (isDir) { - return; - } + camera?.current + ?.takePhoto({ + flash: flash && hasFlash ? 'on' : 'off', + enableShutterSound: !isPlatformMuted, + path, + }) + .then((photo: PhotoFile) => { + // Freeze camera preview now that photo is captured + setDidCapturePhoto(true); + + // Store the receipt on the transaction object in Onyx + const transaction = + isMultiScanEnabled && initialTransaction?.receipt?.source + ? buildOptimisticTransactionAndCreateDraft({ + initialTransaction, + currentUserPersonalDetails, + reportID, + }) + : initialTransaction; + const transactionID = transaction?.transactionID ?? initialTransactionID; + const imageObject: ImageObject = {file: photo, filename: photo.path, source: getPhotoSource(photo.path)}; + cropImageToAspectRatio(imageObject, viewfinderLayout.current?.width, viewfinderLayout.current?.height, undefined, photo.orientation).then(({file, filename, source}) => { + // Add source property to file for prepareRequestPayload compatibility + const cameraFile = { + ...file, + source, + }; + + setMoneyRequestReceipt(transactionID, source, filename, !isEditing, file.type); + + if (isEditing) { + updateScanAndNavigate(cameraFile as FileObject, source); + return; + } + + const newReceiptFiles = [...receiptFiles, {file: cameraFile as FileObject, source, transactionID}]; + setReceiptFiles(newReceiptFiles); - ReactNativeBlobUtil.fs.mkdir(path).catch((error: string) => { - Log.warn('Error creating the directory', error); + if (isMultiScanEnabled) { + setDidCapturePhoto(false); + isCapturingPhoto.current = false; + return; + } + + submitReceipts(newReceiptFiles); }); }) .catch((error: string) => { - Log.warn('Error checking if the directory exists', error); - }) - .then(() => { - camera?.current - ?.takePhoto({ - flash: flash && hasFlash ? 'on' : 'off', - enableShutterSound: !isPlatformMuted, - path, - }) - .then((photo: PhotoFile) => { - // Freeze camera preview now that photo is captured - setDidCapturePhoto(true); - - // Store the receipt on the transaction object in Onyx - const transaction = - isMultiScanEnabled && initialTransaction?.receipt?.source - ? buildOptimisticTransactionAndCreateDraft({ - initialTransaction, - currentUserPersonalDetails, - reportID, - }) - : initialTransaction; - const transactionID = transaction?.transactionID ?? initialTransactionID; - const imageObject: ImageObject = {file: photo, filename: photo.path, source: getPhotoSource(photo.path)}; - cropImageToAspectRatio(imageObject, viewfinderLayout.current?.width, viewfinderLayout.current?.height, undefined, photo.orientation).then( - ({file, filename, source}) => { - // Add source property to file for prepareRequestPayload compatibility - const cameraFile = { - ...file, - source, - }; - - setMoneyRequestReceipt(transactionID, source, filename, !isEditing, file.type); - - if (isEditing) { - updateScanAndNavigate(cameraFile as FileObject, source); - return; - } - - const newReceiptFiles = [...receiptFiles, {file: cameraFile as FileObject, source, transactionID}]; - setReceiptFiles(newReceiptFiles); - - if (isMultiScanEnabled) { - setDidCapturePhoto(false); - isCapturingPhoto.current = false; - return; - } - - submitReceipts(newReceiptFiles); - }, - ); - }) - .catch((error: string) => { - isCapturingPhoto.current = false; - maybeCancelShutterSpan(); - showCameraAlert(); - Log.warn('Error taking photo', error); - }); + isCapturingPhoto.current = false; + maybeCancelShutterSpan(); + showCameraAlert(); + Log.warn('Error taking photo', error); }); // eslint-disable-next-line react-hooks/exhaustive-deps -- askForPermissions is not needed }, [ From d55c5f72a21130d7e63f8db309b54365ba46a631 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 09:13:42 -1000 Subject: [PATCH 03/15] Add span to isolate the "take photo" time --- src/CONST/index.ts | 1 + .../request/step/IOURequestStepScan/index.native.tsx | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 975f0ccf33d4..5073d70b8517 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1788,6 +1788,7 @@ const CONST = { SPAN_OPEN_CREATE_EXPENSE: 'ManualOpenCreateExpense', SPAN_CAMERA_INIT: 'ManualCameraInit', SPAN_SHUTTER_TO_CONFIRMATION: 'ManualShutterToConfirmation', + SPAN_TAKE_PHOTO: 'ManualTakePhoto', SPAN_SUBMIT_EXPENSE: 'ManualCreateExpenseSubmit', SPAN_NAVIGATE_AFTER_EXPENSE_CREATE: 'ManualCreateExpenseNavigation', SPAN_EXPENSE_SERVER_RESPONSE: 'ManualCreateExpenseServerResponse', diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index e8aa08d9ccd8..22183b9cba1f 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -234,6 +234,7 @@ function IOURequestStepScan({ return () => { subscription.remove(); + cancelSpan(CONST.TELEMETRY.SPAN_TAKE_PHOTO); cancelSpan(CONST.TELEMETRY.SPAN_SHUTTER_TO_CONFIRMATION); if (isLoaderVisible) { @@ -306,6 +307,8 @@ function IOURequestStepScan({ const viewfinderLayout = useRef(null); const maybeCancelShutterSpan = useCallback(() => { + cancelSpan(CONST.TELEMETRY.SPAN_TAKE_PHOTO); + if (isMultiScanEnabled) { return; } @@ -314,6 +317,11 @@ function IOURequestStepScan({ }, [isMultiScanEnabled]); const capturePhoto = useCallback(() => { + startSpan(CONST.TELEMETRY.SPAN_TAKE_PHOTO, { + name: CONST.TELEMETRY.SPAN_TAKE_PHOTO, + op: CONST.TELEMETRY.SPAN_TAKE_PHOTO, + }); + if (!isMultiScanEnabled) { startSpan(CONST.TELEMETRY.SPAN_SHUTTER_TO_CONFIRMATION, { name: CONST.TELEMETRY.SPAN_SHUTTER_TO_CONFIRMATION, @@ -370,6 +378,8 @@ function IOURequestStepScan({ const imageObject: ImageObject = {file: photo, filename: photo.path, source: getPhotoSource(photo.path)}; cropImageToAspectRatio(imageObject, viewfinderLayout.current?.width, viewfinderLayout.current?.height, undefined, photo.orientation).then(({file, filename, source}) => { // Add source property to file for prepareRequestPayload compatibility + endSpan(CONST.TELEMETRY.SPAN_TAKE_PHOTO); + const cameraFile = { ...file, source, From dcf18ee67e523b4dc9478d9697dac79433b9815d Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 09:43:39 -1000 Subject: [PATCH 04/15] Select camera format with 4:3 aspect ratio using useCameraFormat Use useCameraFormat to select a known photo format, then pass it to the NavigationAwareCamera component so the camera captures at a predictable aspect ratio. --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 22183b9cba1f..d40dbfe59b68 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -7,7 +7,7 @@ import {Gesture, GestureDetector} from 'react-native-gesture-handler'; import {RESULTS} from 'react-native-permissions'; import Animated, {useAnimatedStyle, useSharedValue, withDelay, withSequence, withSpring, withTiming} from 'react-native-reanimated'; import type {Camera, PhotoFile, Point} from 'react-native-vision-camera'; -import {useCameraDevice} from 'react-native-vision-camera'; +import {useCameraDevice, useCameraFormat} from 'react-native-vision-camera'; import {scheduleOnRN} from 'react-native-worklets'; import ActivityIndicator from '@components/ActivityIndicator'; import AttachmentPicker from '@components/AttachmentPicker'; @@ -74,6 +74,7 @@ function IOURequestStepScan({ const device = useCameraDevice('back', { physicalDevices: ['wide-angle-camera', 'ultra-wide-angle-camera'], }); + const format = useCameraFormat(device, [{photoAspectRatio: 4 / 3}]); const navigateBack = () => { Navigation.goBack(); @@ -492,6 +493,7 @@ function IOURequestStepScan({ Date: Wed, 25 Feb 2026 09:44:03 -1000 Subject: [PATCH 05/15] Constrain viewfinder container to camera format 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. --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index d40dbfe59b68..6f7a94ab0980 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -75,6 +75,8 @@ function IOURequestStepScan({ physicalDevices: ['wide-angle-camera', 'ultra-wide-angle-camera'], }); const format = useCameraFormat(device, [{photoAspectRatio: 4 / 3}]); + // Format dimensions are in landscape orientation, so height/width gives portrait aspect ratio + const cameraAspectRatio = format ? format.photoHeight / format.photoWidth : undefined; const navigateBack = () => { Navigation.goBack(); @@ -487,9 +489,9 @@ function IOURequestStepScan({ )} {cameraPermissionStatus === RESULTS.GRANTED && device != null && ( - + - + Date: Wed, 25 Feb 2026 09:44:31 -1000 Subject: [PATCH 06/15] Remove cropImageToAspectRatio from native capture path 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. --- .../step/IOURequestStepScan/index.native.tsx | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 6f7a94ab0980..2fa76190e41e 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -378,34 +378,34 @@ function IOURequestStepScan({ }) : initialTransaction; const transactionID = transaction?.transactionID ?? initialTransactionID; - const imageObject: ImageObject = {file: photo, filename: photo.path, source: getPhotoSource(photo.path)}; - cropImageToAspectRatio(imageObject, viewfinderLayout.current?.width, viewfinderLayout.current?.height, undefined, photo.orientation).then(({file, filename, source}) => { - // Add source property to file for prepareRequestPayload compatibility - endSpan(CONST.TELEMETRY.SPAN_TAKE_PHOTO); + const source = getPhotoSource(photo.path); + const filename = photo.path; + endSpan(CONST.TELEMETRY.SPAN_TAKE_PHOTO); - const cameraFile = { - ...file, - source, - }; + const cameraFile = { + uri: source, + name: filename, + type: 'image/jpeg', + source, + }; - setMoneyRequestReceipt(transactionID, source, filename, !isEditing, file.type); + setMoneyRequestReceipt(transactionID, source, filename, !isEditing, 'image/jpeg'); - if (isEditing) { - updateScanAndNavigate(cameraFile as FileObject, source); - return; - } + if (isEditing) { + updateScanAndNavigate(cameraFile as FileObject, source); + return; + } - const newReceiptFiles = [...receiptFiles, {file: cameraFile as FileObject, source, transactionID}]; - setReceiptFiles(newReceiptFiles); + const newReceiptFiles = [...receiptFiles, {file: cameraFile as FileObject, source, transactionID}]; + setReceiptFiles(newReceiptFiles); - if (isMultiScanEnabled) { - setDidCapturePhoto(false); - isCapturingPhoto.current = false; - return; - } + if (isMultiScanEnabled) { + setDidCapturePhoto(false); + isCapturingPhoto.current = false; + return; + } - submitReceipts(newReceiptFiles); - }); + submitReceipts(newReceiptFiles); }) .catch((error: string) => { isCapturingPhoto.current = false; From b0a8dd79342146cfa93a7150110931eb41da1357 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 09:45:54 -1000 Subject: [PATCH 07/15] Clean up unused imports after removing crop from native capture Remove cropImageToAspectRatio, ImageObject, LayoutRectangle imports and viewfinderLayout ref that are no longer needed since the native capture path no longer crops. --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 2fa76190e41e..f7717d12155e 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -1,7 +1,6 @@ import {useFocusEffect} from '@react-navigation/core'; import React, {useCallback, useEffect, useRef, useState} from 'react'; import {Alert, AppState, StyleSheet, View} from 'react-native'; -import type {LayoutRectangle} from 'react-native'; import ReactNativeBlobUtil from 'react-native-blob-util'; import {Gesture, GestureDetector} from 'react-native-gesture-handler'; import {RESULTS} from 'react-native-permissions'; @@ -47,8 +46,6 @@ import ROUTES from '@src/ROUTES'; import type {FileObject} from '@src/types/utils/Attachment'; import {getEmptyObject} from '@src/types/utils/EmptyObject'; import CameraPermission from './CameraPermission'; -import {cropImageToAspectRatio} from './cropImageToAspectRatio'; -import type {ImageObject} from './cropImageToAspectRatio'; import NavigationAwareCamera from './NavigationAwareCamera/Camera'; import ReceiptPreviews from './ReceiptPreviews'; import type IOURequestStepScanProps from './types'; @@ -307,8 +304,6 @@ function IOURequestStepScan({ setIsMultiScanEnabled, }); - const viewfinderLayout = useRef(null); - const maybeCancelShutterSpan = useCallback(() => { cancelSpan(CONST.TELEMETRY.SPAN_TAKE_PHOTO); @@ -500,7 +495,6 @@ function IOURequestStepScan({ zoom={device.neutralZoom} photo cameraTabIndex={1} - onLayout={(e) => (viewfinderLayout.current = e.nativeEvent.layout)} forceInactive={isAttachmentPickerActive || didCapturePhoto} onInitialized={handleCameraInitialized} /> From 55cc60b407de59648f53ee0783f463469517e158 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 09:47:05 -1000 Subject: [PATCH 08/15] Request max video and photo resolution in camera format selection 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. --- src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index f7717d12155e..41953ce36433 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -71,7 +71,7 @@ function IOURequestStepScan({ const device = useCameraDevice('back', { physicalDevices: ['wide-angle-camera', 'ultra-wide-angle-camera'], }); - const format = useCameraFormat(device, [{photoAspectRatio: 4 / 3}]); + const format = useCameraFormat(device, [{photoAspectRatio: 4 / 3}, {videoResolution: 'max'}, {photoResolution: 'max'}]); // Format dimensions are in landscape orientation, so height/width gives portrait aspect ratio const cameraAspectRatio = format ? format.photoHeight / format.photoWidth : undefined; From 296c5174378301578fe5bc5579f46d29b150682a Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 10:12:05 -1000 Subject: [PATCH 09/15] Replace inline styles with StyleUtils helpers 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. --- .../iou/request/step/IOURequestStepScan/index.native.tsx | 6 ++++-- src/styles/utils/index.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 41953ce36433..2261d56a1e9a 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -23,6 +23,7 @@ import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hook import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import usePolicy from '@hooks/usePolicy'; +import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {showCameraPermissionsAlert} from '@libs/fileDownload/FileUtils'; @@ -65,6 +66,7 @@ function IOURequestStepScan({ }: IOURequestStepScanProps) { const theme = useTheme(); const styles = useThemeStyles(); + const StyleUtils = useStyleUtils(); const {translate} = useLocalize(); const {isLoaderVisible} = useFullScreenLoaderState(); const {setIsLoaderVisible} = useFullScreenLoaderActions(); @@ -486,7 +488,7 @@ function IOURequestStepScan({ {cameraPermissionStatus === RESULTS.GRANTED && device != null && ( - + diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index 8933b41e1e65..6152900b5b73 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -478,6 +478,13 @@ function getBackgroundColorStyle(backgroundColor: ColorValue): ViewStyle { }; } +function getCameraViewfinderStyle(aspectRatio: number | undefined): ViewStyle { + if (aspectRatio) { + return {aspectRatio, width: '100%', maxHeight: '100%'}; + } + return {flex: 1}; +} + /** * Returns a style for text color */ @@ -1297,6 +1304,7 @@ const staticStyleUtils = { getBackgroundAndBorderStyle, getBackgroundColorStyle, getBackgroundColorWithOpacityStyle, + getCameraViewfinderStyle, getPaddingLeft, getPaddingRight, getPaddingBottom, From 4c5d2cd4793f707dc350e7222447b4a64ce99760 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 10:13:12 -1000 Subject: [PATCH 10/15] Revert blink animation to original subtle values Restore 0.4 opacity / 10ms+50ms timing instead of the more pronounced 1.0 / 50ms+150ms version. --- .../iou/request/step/IOURequestStepScan/useReceiptScan.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts b/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts index 033b02bc14ef..fe3bc75857ac 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts +++ b/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts @@ -117,8 +117,8 @@ function useReceiptScan({ function showBlink() { blinkOpacity.set( - withTiming(1, {duration: 50}, () => { - blinkOpacity.set(withTiming(0, {duration: 150})); + withTiming(0.4, {duration: 10}, () => { + blinkOpacity.set(withTiming(0, {duration: 50})); }), ); HapticFeedback.press(); From e6142a646c3de17bfd33248e859be1e6ff512b25 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 10:32:31 -1000 Subject: [PATCH 11/15] Add useCameraFormat mock to fix IOURequestStepScanTest failures --- tests/ui/IOURequestStepScanTest.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/IOURequestStepScanTest.tsx b/tests/ui/IOURequestStepScanTest.tsx index 67ff02410a0c..e531a8029e64 100644 --- a/tests/ui/IOURequestStepScanTest.tsx +++ b/tests/ui/IOURequestStepScanTest.tsx @@ -52,6 +52,7 @@ jest.mock('@hooks/useFilesValidation', () => { jest.mock('react-native-vision-camera', () => ({ useCameraDevice: jest.fn(() => null), + useCameraFormat: jest.fn(() => null), })); function createMinimalReport(reportID: string, policyID: string): Report { From 28b35aa5be50a13ae05f5fac43e44f2de32e011c Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 12:42:51 -1000 Subject: [PATCH 12/15] Log warn if ReactNativeBlobUtil catches --- .../step/IOURequestStepScan/index.native.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 2261d56a1e9a..0c6b599b1410 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -152,14 +152,19 @@ function IOURequestStepScan({ // Pre-create upload directory to avoid latency during capture const path = getReceiptsUploadFolderPath(); - 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); + 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); }); - }); }, []); const askForPermissions = useCallback(() => { From 957a28564cf2317b054324771884b448012a9dff Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 14:47:20 -1000 Subject: [PATCH 13/15] Use cover strategy for camera viewfinder to eliminate gaps at rounded corners --- src/styles/utils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index 6152900b5b73..78292aa7b69b 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -480,7 +480,7 @@ function getBackgroundColorStyle(backgroundColor: ColorValue): ViewStyle { function getCameraViewfinderStyle(aspectRatio: number | undefined): ViewStyle { if (aspectRatio) { - return {aspectRatio, width: '100%', maxHeight: '100%'}; + return {aspectRatio, minWidth: '100%', minHeight: '100%'}; } return {flex: 1}; } From 6c23289eeaa5fe8fcb021fd9b9b0a22a1ee21b8d Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 25 Feb 2026 14:50:05 -1000 Subject: [PATCH 14/15] Add pronounced blink back --- .../iou/request/step/IOURequestStepScan/useReceiptScan.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts b/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts index fe3bc75857ac..033b02bc14ef 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts +++ b/src/pages/iou/request/step/IOURequestStepScan/useReceiptScan.ts @@ -117,8 +117,8 @@ function useReceiptScan({ function showBlink() { blinkOpacity.set( - withTiming(0.4, {duration: 10}, () => { - blinkOpacity.set(withTiming(0, {duration: 50})); + withTiming(1, {duration: 50}, () => { + blinkOpacity.set(withTiming(0, {duration: 150})); }), ); HapticFeedback.press(); From b097233351fec713e92ca667c57e6aea02219b1a Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 2 Mar 2026 14:21:18 -1000 Subject: [PATCH 15/15] move SPAN_RECEIPT_CAPTURE cancel --- src/pages/iou/request/step/IOURequestStepScan/index.native.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 1992027741c9..c2044a833ed5 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -312,12 +312,11 @@ function IOURequestStepScan({ }); const maybeCancelShutterSpan = useCallback(() => { - cancelSpan(CONST.TELEMETRY.SPAN_RECEIPT_CAPTURE); - if (isMultiScanEnabled) { return; } + cancelSpan(CONST.TELEMETRY.SPAN_RECEIPT_CAPTURE); cancelSpan(CONST.TELEMETRY.SPAN_SHUTTER_TO_CONFIRMATION); }, [isMultiScanEnabled]);