Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {StackCardInterpolationProps, StackScreenProps} from '@react-navigation/stack';
import {createStackNavigator} from '@react-navigation/stack';
import React, {useMemo, useRef} from 'react';
import {View} from 'react-native';
import {InteractionManager, View} from 'react-native';
import NoDropZone from '@components/DragAndDrop/NoDropZone';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -62,7 +62,11 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) {
) {
return;
}
abandonReviewDuplicateTransactions();
// Delay clearing review duplicate data till the RHP is completely closed
// to avoid not found showing briefly in confirmation page when RHP is closing
InteractionManager.runAfterInteractions(() => {
Comment thread
gijoe0295 marked this conversation as resolved.
abandonReviewDuplicateTransactions();
});
},
}}
id={NAVIGATORS.RIGHT_MODAL_NAVIGATOR}
Expand Down
6 changes: 6 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5607,6 +5607,11 @@ function canAccessReport(report: OnyxEntry<Report>, policies: OnyxCollection<Pol
return true;
}

// eslint-disable-next-line rulesdir/no-negated-variables
function isReportNotFound(report: OnyxEntry<Report>): boolean {
return !!report?.errorFields?.notFound;
}

/**
* Check if the report is the parent report of the currently viewed report or at least one child report has report action
*/
Expand Down Expand Up @@ -7565,6 +7570,7 @@ export {
buildParticipantsFromAccountIDs,
buildTransactionThread,
canAccessReport,
isReportNotFound,
canAddTransaction,
canDeleteTransaction,
canBeAutoReimbursed,
Expand Down
24 changes: 21 additions & 3 deletions src/pages/TransactionDuplicate/Confirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {useOnyx} from 'react-native-onyx';
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import Button from '@components/Button';
import FixedFooter from '@components/FixedFooter';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MoneyRequestView from '@components/ReportActionItem/MoneyRequestView';
import ScreenWrapper from '@components/ScreenWrapper';
Expand All @@ -20,19 +21,22 @@ import type {TransactionDuplicateNavigatorParamList} from '@libs/Navigation/type
import variables from '@styles/variables';
import * as IOU from '@src/libs/actions/IOU';
import * as ReportActionsUtils from '@src/libs/ReportActionsUtils';
import * as ReportUtils from '@src/libs/ReportUtils';
import * as TransactionUtils from '@src/libs/TransactionUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type {Transaction} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';

function Confirmation() {
const styles = useThemeStyles();
const {translate} = useLocalize();
const route = useRoute<RouteProp<TransactionDuplicateNavigatorParamList, typeof SCREENS.TRANSACTION_DUPLICATE.REVIEW>>();
const [reviewDuplicates] = useOnyx(ONYXKEYS.REVIEW_DUPLICATES);
const [reviewDuplicates, reviewDuplicatesResult] = useOnyx(ONYXKEYS.REVIEW_DUPLICATES);
const transaction = useMemo(() => TransactionUtils.buildNewTransactionAfterReviewingDuplicates(reviewDuplicates), [reviewDuplicates]);
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`);
const [report, reportResult] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`);
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transaction?.reportID}`);
const reportAction = Object.values(reportActions ?? {}).find(
(action) => ReportActionsUtils.isMoneyRequestAction(action) && ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID === reviewDuplicates?.transactionID,
Expand All @@ -56,13 +60,27 @@ function Confirmation() {
[report, reportAction],
);

const reportTransactionID = TransactionUtils.getTransactionID(report?.reportID ?? '');
const doesTransactionBelongToReport = reviewDuplicates?.transactionID === reportTransactionID || reviewDuplicates?.duplicates.includes(reportTransactionID);

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage =
isEmptyObject(report) ||
!ReportUtils.isValidReport(report) ||

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When report has been loaded from Onyx but was still loading from the BE, it's prefilled with reportName without reportID.

ReportUtils.isReportNotFound(report) ||
(reviewDuplicatesResult.status === 'loaded' && (!transaction?.transactionID || !doesTransactionBelongToReport));

if (isLoadingOnyxValue(reviewDuplicatesResult, reportResult)) {
return <FullScreenLoadingIndicator />;

@gijoe0295 gijoe0295 Jul 25, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to the isExiting check as explained above, we should show a loading indicator when the data is loading, otherwise we would have empty data shows briefly.

}

return (
<ScreenWrapper
testID={Confirmation.displayName}
shouldShowOfflineIndicator
>
{({safeAreaPaddingBottomStyle}) => (
<FullPageNotFoundView shouldShow={!reviewDuplicates}>
<FullPageNotFoundView shouldShow={shouldShowNotFoundPage}>
<View style={[styles.flex1, safeAreaPaddingBottomStyle]}>
<HeaderWithBackButton title={translate('iou.reviewDuplicates')} />
<ScrollView>
Expand Down