11import { useRoute } from '@react-navigation/native' ;
2- import React , { useMemo } from 'react' ;
2+ import React , { useEffect , useMemo } from 'react' ;
33import { View } from 'react-native' ;
44import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView' ;
55import Button from '@components/Button' ;
66import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
7+ import ReportActionsSkeletonView from '@components/ReportActionsSkeletonView' ;
8+ import ReportHeaderSkeletonView from '@components/ReportHeaderSkeletonView' ;
79import ScreenWrapper from '@components/ScreenWrapper' ;
810import Text from '@components/Text' ;
911import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' ;
1012import useLocalize from '@hooks/useLocalize' ;
1113import useOnyx from '@hooks/useOnyx' ;
1214import useThemeStyles from '@hooks/useThemeStyles' ;
1315import useTransactionViolations from '@hooks/useTransactionViolations' ;
16+ import { openReport } from '@libs/actions/Report' ;
1417import { dismissDuplicateTransactionViolation } from '@libs/actions/Transaction' ;
1518import Navigation from '@libs/Navigation/Navigation' ;
1619import type { PlatformStackRouteProp } from '@libs/Navigation/PlatformStackNavigation/types' ;
@@ -28,6 +31,7 @@ function TransactionDuplicateReview() {
2831 const route = useRoute < PlatformStackRouteProp < TransactionDuplicateNavigatorParamList , typeof SCREENS . TRANSACTION_DUPLICATE . REVIEW > > ( ) ;
2932 const currentPersonalDetails = useCurrentUserPersonalDetails ( ) ;
3033 const [ report ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT } ${ route . params . threadReportID } ` , { canBeMissing : true } ) ;
34+ const [ reportMetadata ] = useOnyx ( `${ ONYXKEYS . COLLECTION . REPORT_METADATA } ${ route . params . threadReportID } ` , { canBeMissing : true } ) ;
3135 const reportAction = getReportAction ( report ?. parentReportID , report ?. parentReportActionID ) ;
3236 const transactionID = getLinkedTransactionID ( reportAction , report ?. reportID ) ?? undefined ;
3337 const transactionViolations = useTransactionViolations ( transactionID ) ;
@@ -56,9 +60,34 @@ function TransactionDuplicateReview() {
5660
5761 const hasSettledOrApprovedTransaction = transactions ?. some ( ( transaction ) => isSettled ( transaction ?. reportID ) || isReportIDApproved ( transaction ?. reportID ) ) ;
5862
63+ useEffect ( ( ) => {
64+ if ( ! route . params . threadReportID || report ?. reportID ) {
65+ return ;
66+ }
67+ openReport ( route . params . threadReportID ) ;
68+ } , [ report ?. reportID , route . params . threadReportID ] ) ;
69+
70+ const isLoadingPage = ( ! report ?. reportID && reportMetadata ?. isLoadingInitialReportActions !== false ) || ! reportAction ?. reportActionID ;
71+
72+ // eslint-disable-next-line rulesdir/no-negated-variables
73+ const shouldShowNotFound = ! isLoadingPage && ! transactionID ;
74+
75+ if ( isLoadingPage ) {
76+ return (
77+ < ScreenWrapper testID = { TransactionDuplicateReview . displayName } >
78+ < View style = { [ styles . flex1 ] } >
79+ < View style = { [ styles . appContentHeader , styles . borderBottom ] } >
80+ < ReportHeaderSkeletonView onBackButtonPress = { ( ) => { } } />
81+ </ View >
82+ < ReportActionsSkeletonView />
83+ </ View >
84+ </ ScreenWrapper >
85+ ) ;
86+ }
87+
5988 return (
6089 < ScreenWrapper testID = { TransactionDuplicateReview . displayName } >
61- < FullPageNotFoundView shouldShow = { ! transactionID } >
90+ < FullPageNotFoundView shouldShow = { shouldShowNotFound } >
6291 < HeaderWithBackButton
6392 title = { translate ( 'iou.reviewDuplicates' ) }
6493 onBackButtonPress = { ( ) => Navigation . goBack ( route . params . backTo ) }
0 commit comments