Skip to content

Commit 5a93e11

Browse files
luacmartinsOSBotify
authored andcommitted
Merge pull request #49916 from bernhardoj/fix/missing-header
[CP Staging] Fix missing header in scan page (cherry picked from commit 648b647) (CP triggered by luacmartins)
1 parent 18273f6 commit 5a93e11

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/pages/iou/request/step/IOURequestStepScan/index.native.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function IOURequestStepScan({
6363
physicalDevices: ['wide-angle-camera', 'ultra-wide-angle-camera'],
6464
});
6565

66+
const isEditing = action === CONST.IOU.ACTION.EDIT;
6667
const hasFlash = !!device?.hasFlash;
6768
const camera = useRef<Camera>(null);
6869
const [flash, setFlash] = useState(false);
@@ -411,9 +412,9 @@ function IOURequestStepScan({
411412
// Store the receipt on the transaction object in Onyx
412413
// On Android devices, fetching blob for a file with name containing spaces fails to retrieve the type of file.
413414
// So, let us also save the file type in receipt for later use during blob fetch
414-
IOU.setMoneyRequestReceipt(transactionID, file?.uri ?? '', file.name ?? '', action !== CONST.IOU.ACTION.EDIT, file.type);
415+
IOU.setMoneyRequestReceipt(transactionID, file?.uri ?? '', file.name ?? '', !isEditing, file.type);
415416

416-
if (action === CONST.IOU.ACTION.EDIT) {
417+
if (isEditing) {
417418
updateScanAndNavigate(file, file?.uri ?? '');
418419
return;
419420
}
@@ -448,10 +449,10 @@ function IOURequestStepScan({
448449
.then((photo: PhotoFile) => {
449450
// Store the receipt on the transaction object in Onyx
450451
const source = getPhotoSource(photo.path);
451-
IOU.setMoneyRequestReceipt(transactionID, source, photo.path, action !== CONST.IOU.ACTION.EDIT);
452+
IOU.setMoneyRequestReceipt(transactionID, source, photo.path, !isEditing);
452453

453454
FileUtils.readFileAsync(source, photo.path, (file) => {
454-
if (action === CONST.IOU.ACTION.EDIT) {
455+
if (isEditing) {
455456
updateScanAndNavigate(file, source);
456457
return;
457458
}
@@ -464,7 +465,7 @@ function IOURequestStepScan({
464465
showCameraAlert();
465466
Log.warn('Error taking photo', error);
466467
});
467-
}, [cameraPermissionStatus, didCapturePhoto, flash, hasFlash, user?.isMutedAllSounds, translate, transactionID, action, navigateToConfirmationStep, updateScanAndNavigate]);
468+
}, [isEditing, cameraPermissionStatus, didCapturePhoto, flash, hasFlash, user?.isMutedAllSounds, translate, transactionID, navigateToConfirmationStep, updateScanAndNavigate]);
468469

469470
// Wait for camera permission status to render
470471
if (cameraPermissionStatus == null) {
@@ -476,7 +477,7 @@ function IOURequestStepScan({
476477
includeSafeAreaPaddingBottom
477478
headerTitle={translate('common.receipt')}
478479
onBackButtonPress={navigateBack}
479-
shouldShowWrapper={!!backTo}
480+
shouldShowWrapper={!!backTo || isEditing}
480481
testID={IOURequestStepScan.displayName}
481482
>
482483
{isLoadingReceipt && <FullScreenLoadingIndicator />}

src/pages/iou/request/step/IOURequestStepScan/index.tsx

+7-6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ function IOURequestStepScan({
8686
const tabIndex = 1;
8787
const isTabActive = useTabNavigatorFocus({tabIndex});
8888

89+
const isEditing = action === CONST.IOU.ACTION.EDIT;
8990
const defaultTaxCode = TransactionUtils.getDefaultTaxCode(policy, transaction);
9091
const transactionTaxCode = (transaction?.taxCode ? transaction?.taxCode : defaultTaxCode) ?? '';
9192
const transactionTaxAmount = transaction?.taxAmount ?? 0;
@@ -444,9 +445,9 @@ function IOURequestStepScan({
444445
// Store the receipt on the transaction object in Onyx
445446
const source = URL.createObjectURL(file as Blob);
446447
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
447-
IOU.setMoneyRequestReceipt(transactionID, source, file.name || '', action !== CONST.IOU.ACTION.EDIT);
448+
IOU.setMoneyRequestReceipt(transactionID, source, file.name || '', !isEditing);
448449

449-
if (action === CONST.IOU.ACTION.EDIT) {
450+
if (isEditing) {
450451
updateScanAndNavigate(file, source);
451452
return;
452453
}
@@ -478,15 +479,15 @@ function IOURequestStepScan({
478479
const filename = `receipt_${Date.now()}.png`;
479480
const file = FileUtils.base64ToFile(imageBase64 ?? '', filename);
480481
const source = URL.createObjectURL(file);
481-
IOU.setMoneyRequestReceipt(transactionID, source, file.name, action !== CONST.IOU.ACTION.EDIT);
482+
IOU.setMoneyRequestReceipt(transactionID, source, file.name, !isEditing);
482483

483-
if (action === CONST.IOU.ACTION.EDIT) {
484+
if (isEditing) {
484485
updateScanAndNavigate(file, source);
485486
return;
486487
}
487488

488489
navigateToConfirmationStep(file, source);
489-
}, [action, transactionID, updateScanAndNavigate, navigateToConfirmationStep, requestCameraPermission]);
490+
}, [isEditing, transactionID, updateScanAndNavigate, navigateToConfirmationStep, requestCameraPermission]);
490491

491492
const clearTorchConstraints = useCallback(() => {
492493
if (!trackRef.current) {
@@ -695,7 +696,7 @@ function IOURequestStepScan({
695696
<StepScreenDragAndDropWrapper
696697
headerTitle={translate('common.receipt')}
697698
onBackButtonPress={navigateBack}
698-
shouldShowWrapper={!!backTo}
699+
shouldShowWrapper={!!backTo || isEditing}
699700
testID={IOURequestStepScan.displayName}
700701
>
701702
{(isDraggingOverWrapper) => (

0 commit comments

Comments
 (0)