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
dcfd9e7
show not found page for invalid report or transaction in review dupli…
gijoe0295 Jul 22, 2024
57113d5
fix: not found briefly when data is loading
gijoe0295 Jul 24, 2024
d0dec61
fix: not found briefly when closing rhp
gijoe0295 Jul 24, 2024
25dd71a
fix: empty data briefly when refresh page
gijoe0295 Jul 24, 2024
d235782
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 Jul 25, 2024
b001f62
show not found when report is undefined
gijoe0295 Jul 25, 2024
a6f5190
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 Jul 31, 2024
e854d85
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 Jul 31, 2024
e08a9bd
resolve feedbacks
gijoe0295 Aug 1, 2024
270ffd1
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 Aug 1, 2024
9f2294e
fix: not found when report is loading
gijoe0295 Aug 1, 2024
37d8dd0
show not found in case transaction and report does not match
gijoe0295 Aug 1, 2024
2f6fe1e
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 Aug 7, 2024
f4e8685
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 Aug 12, 2024
4d8ae30
fix: not found when select the other duplicate that does not belong t…
gijoe0295 Aug 12, 2024
b2ee36c
delay abandonReviewDuplicateTransactions function call and eliminate …
gijoe0295 Aug 14, 2024
545d78e
add comment
gijoe0295 Aug 15, 2024
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