@@ -11,13 +11,13 @@ import useLocalize from '@hooks/useLocalize';
1111import useNetwork from '@hooks/useNetwork' ;
1212import useOnyx from '@hooks/useOnyx' ;
1313import usePolicy from '@hooks/usePolicy' ;
14- import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
1514import useThemeStyles from '@hooks/useThemeStyles' ;
1615import { detachReceipt , navigateToStartStepIfScanFileCannotBeRead , removeMoneyRequestOdometerImage , replaceReceipt , setMoneyRequestReceipt } from '@libs/actions/IOU' ;
1716import { openReport } from '@libs/actions/Report' ;
1817import cropOrRotateImage from '@libs/cropOrRotateImage' ;
1918import fetchImage from '@libs/fetchImage' ;
2019import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID' ;
20+ import getPlatform from '@libs/getPlatform' ;
2121import Navigation from '@libs/Navigation/Navigation' ;
2222import { getThumbnailAndImageURIs } from '@libs/ReceiptUtils' ;
2323import { getReportAction , isTrackExpenseAction } from '@libs/ReportActionsUtils' ;
@@ -30,7 +30,6 @@ import type {AttachmentModalScreenProps} from '@pages/media/AttachmentModalScree
3030import CONST from '@src/CONST' ;
3131import ONYXKEYS from '@src/ONYXKEYS' ;
3232import ROUTES from '@src/ROUTES' ;
33- import type { Route } from '@src/ROUTES' ;
3433import type SCREENS from '@src/SCREENS' ;
3534import type { ReceiptSource } from '@src/types/onyx/Transaction' ;
3635import type { FileObject } from '@src/types/utils/Attachment' ;
@@ -52,7 +51,8 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre
5251 const [ session ] = useOnyx ( ONYXKEYS . SESSION ) ;
5352 const [ introSelected ] = useOnyx ( ONYXKEYS . NVP_INTRO_SELECTED ) ;
5453 const policy = usePolicy ( report ?. policyID ) ;
55- const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
54+ const platform = getPlatform ( ) ;
55+ const isNative = platform === CONST . PLATFORM . ANDROID || platform === CONST . PLATFORM . IOS ;
5656
5757 // If we have a merge transaction, we need to use the receipt from the merge transaction
5858 const [ mergeTransaction ] = useOnyx ( `${ ONYXKEYS . COLLECTION . MERGE_TRANSACTION } ${ getNonEmptyStringOnyxID ( mergeTransactionID ) } ` ) ;
@@ -506,23 +506,27 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre
506506 < Button
507507 icon = { expensifyIcons . Camera }
508508 onPress = { ( ) => {
509- const destinationRoute : Route = isOdometerImage
510- ? ROUTES . ODOMETER_IMAGE . getRoute ( action ?? CONST . IOU . ACTION . CREATE , iouType , transactionID , reportID , imageType )
511- : ROUTES . MONEY_REQUEST_STEP_SCAN . getRoute (
512- action ?? CONST . IOU . ACTION . EDIT ,
513- iouType ,
514- draftTransactionID ?? transaction ?. transactionID ,
515- report ?. reportID ,
516- Navigation . getActiveRoute ( ) ,
517- ) ;
518-
519- if ( shouldUseNarrowLayout ) {
520- Navigation . navigate ( destinationRoute , { forceReplace : true } ) ;
509+ const getDestinationRoute = ( ) => {
510+ return isOdometerImage
511+ ? ROUTES . ODOMETER_IMAGE . getRoute ( action ?? CONST . IOU . ACTION . CREATE , iouType , transactionID , reportID , imageType )
512+ : ROUTES . MONEY_REQUEST_STEP_SCAN . getRoute (
513+ action ?? CONST . IOU . ACTION . EDIT ,
514+ iouType ,
515+ draftTransactionID ?? transaction ?. transactionID ,
516+ report ?. reportID ,
517+ Navigation . getActiveRoute ( ) ,
518+ ) ;
519+ } ;
520+ if ( isNative ) {
521+ Navigation . goBack ( ) ;
522+ Navigation . setNavigationActionToMicrotaskQueue ( ( ) => {
523+ Navigation . navigate ( getDestinationRoute ( ) ) ;
524+ } ) ;
521525 return ;
522526 }
523527
524528 Navigation . dismissModal ( {
525- callback : ( ) => Navigation . navigate ( destinationRoute ) ,
529+ callback : ( ) => Navigation . navigate ( getDestinationRoute ( ) ) ,
526530 } ) ;
527531 } }
528532 text = { translate ( 'common.replace' ) }
@@ -563,7 +567,7 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre
563567 draftTransactionID ,
564568 transaction ?. transactionID ,
565569 report ?. reportID ,
566- shouldUseNarrowLayout ,
570+ isNative ,
567571 ] ) ;
568572
569573 const customAttachmentContent = useMemo ( ( ) => {
0 commit comments