-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Show not found for invalid report or transaction in review duplicates confirmation page #45965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 12 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 57113d5
fix: not found briefly when data is loading
gijoe0295 d0dec61
fix: not found briefly when closing rhp
gijoe0295 25dd71a
fix: empty data briefly when refresh page
gijoe0295 d235782
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 b001f62
show not found when report is undefined
gijoe0295 a6f5190
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 e854d85
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 e08a9bd
resolve feedbacks
gijoe0295 270ffd1
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 9f2294e
fix: not found when report is loading
gijoe0295 37d8dd0
show not found in case transaction and report does not match
gijoe0295 2f6fe1e
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 f4e8685
Merge branch 'main' of https://github.com/gijoe0295/App into gijoe/45835
gijoe0295 4d8ae30
fix: not found when select the other duplicate that does not belong t…
gijoe0295 b2ee36c
delay abandonReviewDuplicateTransactions function call and eliminate …
gijoe0295 545d78e
add comment
gijoe0295 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import type {RouteProp} from '@react-navigation/native'; | ||
import {useRoute} from '@react-navigation/native'; | ||
import React, {useCallback, useMemo} from 'react'; | ||
import {useNavigation, useRoute} from '@react-navigation/native'; | ||
import React, {useCallback, useEffect, useMemo, useState} from 'react'; | ||
import {View} from 'react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
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'; | ||
|
@@ -20,19 +21,24 @@ 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 navigation = useNavigation(); | ||
const route = useRoute<RouteProp<TransactionDuplicateNavigatorParamList, typeof SCREENS.TRANSACTION_DUPLICATE.REVIEW>>(); | ||
const [reviewDuplicates] = useOnyx(ONYXKEYS.REVIEW_DUPLICATES); | ||
const [isExitingPage, setIsExitingPage] = useState(false); | ||
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, | ||
|
@@ -56,13 +62,34 @@ function Confirmation() { | |
[report, reportAction], | ||
); | ||
|
||
useEffect(() => { | ||
const unsubscribeBeforeRemove = navigation.addListener('beforeRemove', () => { | ||
setIsExitingPage(true); | ||
}); | ||
|
||
return unsubscribeBeforeRemove; | ||
}, [navigation]); | ||
|
||
const doesTransactionBelongToReport = TransactionUtils.getTransactionID(report?.reportID ?? '') === transaction.transactionID; | ||
|
||
// eslint-disable-next-line rulesdir/no-negated-variables | ||
const shouldShowNotFoundPage = | ||
isEmptyObject(report) || | ||
!ReportUtils.isValidReport(report) || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When |
||
ReportUtils.isReportNotFound(report) || | ||
(!isExitingPage && reviewDuplicatesResult.status === 'loaded' && (!transaction?.transactionID || !doesTransactionBelongToReport)); | ||
|
||
if (isLoadingOnyxValue(reviewDuplicatesResult, reportResult)) { | ||
return <FullScreenLoadingIndicator />; | ||
} | ||
|
||
return ( | ||
<ScreenWrapper | ||
testID={Confirmation.displayName} | ||
shouldShowOfflineIndicator | ||
> | ||
{({safeAreaPaddingBottomStyle}) => ( | ||
<FullPageNotFoundView shouldShow={!reviewDuplicates}> | ||
<FullPageNotFoundView shouldShow={shouldShowNotFoundPage}> | ||
<View style={[styles.flex1, safeAreaPaddingBottomStyle]}> | ||
<HeaderWithBackButton title={translate('iou.reviewDuplicates')} /> | ||
<ScrollView> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you replaced the
reportID
in URL with any valid transaction thread report ID, it would still show transaction data from that thread report (which is not the correct transaction fromreviewDuplicates
. We should check if the transaction fromreviewDuplicates
matches/belongs toreport
.