diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 05ebdc1dfc62..f6b4c44c80ae 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -63,6 +63,7 @@ function IOURequestStepScan({ physicalDevices: ['wide-angle-camera', 'ultra-wide-angle-camera'], }); + const isEditing = action === CONST.IOU.ACTION.EDIT; const hasFlash = !!device?.hasFlash; const camera = useRef(null); const [flash, setFlash] = useState(false); @@ -411,9 +412,9 @@ function IOURequestStepScan({ // Store the receipt on the transaction object in Onyx // On Android devices, fetching blob for a file with name containing spaces fails to retrieve the type of file. // So, let us also save the file type in receipt for later use during blob fetch - IOU.setMoneyRequestReceipt(transactionID, file?.uri ?? '', file.name ?? '', action !== CONST.IOU.ACTION.EDIT, file.type); + IOU.setMoneyRequestReceipt(transactionID, file?.uri ?? '', file.name ?? '', !isEditing, file.type); - if (action === CONST.IOU.ACTION.EDIT) { + if (isEditing) { updateScanAndNavigate(file, file?.uri ?? ''); return; } @@ -448,10 +449,10 @@ function IOURequestStepScan({ .then((photo: PhotoFile) => { // Store the receipt on the transaction object in Onyx const source = getPhotoSource(photo.path); - IOU.setMoneyRequestReceipt(transactionID, source, photo.path, action !== CONST.IOU.ACTION.EDIT); + IOU.setMoneyRequestReceipt(transactionID, source, photo.path, !isEditing); FileUtils.readFileAsync(source, photo.path, (file) => { - if (action === CONST.IOU.ACTION.EDIT) { + if (isEditing) { updateScanAndNavigate(file, source); return; } @@ -464,7 +465,7 @@ function IOURequestStepScan({ showCameraAlert(); Log.warn('Error taking photo', error); }); - }, [cameraPermissionStatus, didCapturePhoto, flash, hasFlash, user?.isMutedAllSounds, translate, transactionID, action, navigateToConfirmationStep, updateScanAndNavigate]); + }, [isEditing, cameraPermissionStatus, didCapturePhoto, flash, hasFlash, user?.isMutedAllSounds, translate, transactionID, navigateToConfirmationStep, updateScanAndNavigate]); // Wait for camera permission status to render if (cameraPermissionStatus == null) { @@ -476,7 +477,7 @@ function IOURequestStepScan({ includeSafeAreaPaddingBottom headerTitle={translate('common.receipt')} onBackButtonPress={navigateBack} - shouldShowWrapper={!!backTo} + shouldShowWrapper={!!backTo || isEditing} testID={IOURequestStepScan.displayName} > {isLoadingReceipt && } diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 58f20b281937..19a82b9011e6 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -86,6 +86,7 @@ function IOURequestStepScan({ const tabIndex = 1; const isTabActive = useTabNavigatorFocus({tabIndex}); + const isEditing = action === CONST.IOU.ACTION.EDIT; const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transaction); const transactionTaxCode = (transaction?.taxCode ? transaction?.taxCode : defaultTaxCode) ?? ''; const transactionTaxAmount = transaction?.taxAmount ?? 0; @@ -444,9 +445,9 @@ function IOURequestStepScan({ // Store the receipt on the transaction object in Onyx const source = URL.createObjectURL(file as Blob); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - IOU.setMoneyRequestReceipt(transactionID, source, file.name || '', action !== CONST.IOU.ACTION.EDIT); + IOU.setMoneyRequestReceipt(transactionID, source, file.name || '', !isEditing); - if (action === CONST.IOU.ACTION.EDIT) { + if (isEditing) { updateScanAndNavigate(file, source); return; } @@ -478,15 +479,15 @@ function IOURequestStepScan({ const filename = `receipt_${Date.now()}.png`; const file = FileUtils.base64ToFile(imageBase64 ?? '', filename); const source = URL.createObjectURL(file); - IOU.setMoneyRequestReceipt(transactionID, source, file.name, action !== CONST.IOU.ACTION.EDIT); + IOU.setMoneyRequestReceipt(transactionID, source, file.name, !isEditing); - if (action === CONST.IOU.ACTION.EDIT) { + if (isEditing) { updateScanAndNavigate(file, source); return; } navigateToConfirmationStep(file, source); - }, [action, transactionID, updateScanAndNavigate, navigateToConfirmationStep, requestCameraPermission]); + }, [isEditing, transactionID, updateScanAndNavigate, navigateToConfirmationStep, requestCameraPermission]); const clearTorchConstraints = useCallback(() => { if (!trackRef.current) { @@ -695,7 +696,7 @@ function IOURequestStepScan({ {(isDraggingOverWrapper) => (