-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix not found view of linked action doesn't have back button #46132
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,8 @@ | |
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; | ||
import {useOnyx, withOnyx} from 'react-native-onyx'; | ||
import Banner from '@components/Banner'; | ||
import BlockingView from '@components/BlockingViews/BlockingView'; | ||
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
import DragAndDropProvider from '@components/DragAndDrop/Provider'; | ||
import * as Illustrations from '@components/Icon/Illustrations'; | ||
import MoneyReportHeader from '@components/MoneyReportHeader'; | ||
import MoneyRequestHeader from '@components/MoneyRequestHeader'; | ||
import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
|
@@ -43,7 +41,7 @@ | |
import shouldFetchReport from '@libs/shouldFetchReport'; | ||
import * as ValidationUtils from '@libs/ValidationUtils'; | ||
import type {AuthScreensParamList} from '@navigation/types'; | ||
import variables from '@styles/variables'; | ||
import * as ComposerActions from '@userActions/Composer'; | ||
import * as Report from '@userActions/Report'; | ||
import CONST from '@src/CONST'; | ||
|
@@ -416,6 +414,12 @@ | |
? reportActions.length > 0 | ||
: reportActions.length >= CONST.REPORT.MIN_INITIAL_REPORT_ACTION_COUNT || isPendingActionExist || (doesCreatedActionExists() && reportActions.length > 0); | ||
|
||
const isLinkedActionDeleted = useMemo(() => !!linkedAction && !ReportActionsUtils.shouldReportActionBeVisible(linkedAction, linkedAction.reportActionID), [linkedAction]); | ||
const isLinkedActionInaccessibleWhisper = useMemo( | ||
() => !!linkedAction && ReportActionsUtils.isWhisperAction(linkedAction) && !(linkedAction?.whisperedToAccountIDs ?? []).includes(currentUserAccountID), | ||
[currentUserAccountID, linkedAction], | ||
); | ||
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. This is just moving up the variable definition. |
||
|
||
/** | ||
* Using logical OR operator because with nullish coalescing operator, when `isLoadingApp` is false, the right hand side of the operator | ||
* is not evaluated. This causes issues where we have `isLoading` set to false and later set to true and then set to false again. | ||
|
@@ -431,10 +435,24 @@ | |
!isCurrentReportLoadedFromOnyx || | ||
isLoading; | ||
|
||
const shouldShowNotFoundLinkedAction = | ||
(!isLinkedActionInaccessibleWhisper && isLinkedActionDeleted) || | ||
(shouldShowSkeleton && | ||
!reportMetadata.isLoadingInitialReportActions && | ||
!!reportActionIDFromRoute && | ||
!!sortedAllReportActions && | ||
sortedAllReportActions?.length > 0 && | ||
reportActions.length === 0 && | ||
!isLinkingToMessage); | ||
|
||
const currentReportIDFormRoute = route.params?.reportID; | ||
|
||
// eslint-disable-next-line rulesdir/no-negated-variables | ||
const shouldShowNotFoundPage = useMemo((): boolean => { | ||
if (shouldShowNotFoundLinkedAction) { | ||
return true; | ||
} | ||
|
||
// Wait until we're sure the app is done loading (needs to be a strict equality check since it's undefined initially) | ||
if (isLoadingApp !== false) { | ||
return false; | ||
|
@@ -454,7 +472,17 @@ | |
return true; | ||
} | ||
return !!currentReportIDFormRoute && !ReportUtils.isValidReportIDFromPath(currentReportIDFormRoute); | ||
}, [isLoadingApp, finishedLoadingApp, report.reportID, isOptimisticDelete, reportMetadata?.isLoadingInitialReportActions, userLeavingStatus, shouldHideReport, currentReportIDFormRoute]); | ||
}, [ | ||
shouldShowNotFoundLinkedAction, | ||
isLoadingApp, | ||
finishedLoadingApp, | ||
report.reportID, | ||
isOptimisticDelete, | ||
reportMetadata?.isLoadingInitialReportActions, | ||
userLeavingStatus, | ||
shouldHideReport, | ||
currentReportIDFormRoute, | ||
]); | ||
|
||
const fetchReport = useCallback(() => { | ||
Report.openReport(reportIDFromRoute, reportActionIDFromRoute); | ||
|
@@ -708,12 +736,6 @@ | |
fetchReport(); | ||
}, [fetchReport]); | ||
|
||
const isLinkedActionDeleted = useMemo(() => !!linkedAction && !ReportActionsUtils.shouldReportActionBeVisible(linkedAction, linkedAction.reportActionID), [linkedAction]); | ||
const isLinkedActionInaccessibleWhisper = useMemo( | ||
() => !!linkedAction && ReportActionsUtils.isWhisperAction(linkedAction) && !(linkedAction?.whisperedToAccountIDs ?? []).includes(currentUserAccountID), | ||
[currentUserAccountID, linkedAction], | ||
); | ||
|
||
// If user redirects to an inaccessible whisper via a deeplink, on a report they have access to, | ||
// then we set reportActionID as empty string, so we display them the report and not the "Not found page". | ||
useEffect(() => { | ||
|
@@ -733,29 +755,6 @@ | |
Report.readNewestAction(report.reportID); | ||
}, [report]); | ||
|
||
if ( | ||
(!isLinkedActionInaccessibleWhisper && isLinkedActionDeleted) || | ||
(shouldShowSkeleton && | ||
!reportMetadata.isLoadingInitialReportActions && | ||
reportActionIDFromRoute && | ||
sortedAllReportActions && | ||
sortedAllReportActions?.length > 0 && | ||
reportActions.length === 0 && | ||
!isLinkingToMessage) | ||
) { | ||
return ( | ||
<BlockingView | ||
icon={Illustrations.ToddBehindCloud} | ||
iconWidth={variables.modalTopIconWidth} | ||
iconHeight={variables.modalTopIconHeight} | ||
title={translate('notFound.notHere')} | ||
shouldShowLink | ||
linkKey="notFound.noAccess" | ||
onLinkPress={navigateToEndOfReport} | ||
/> | ||
); | ||
} | ||
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. Refactored it so we use FullPageNotFoundView below. It's already wrapped in ScreenWrapper too which adds safe inset for native platform. |
||
|
||
return ( | ||
<ActionListContext.Provider value={actionListValue}> | ||
<ReactionListContext.Provider value={reactionListRef}> | ||
|
@@ -767,10 +766,12 @@ | |
> | ||
<FullPageNotFoundView | ||
shouldShow={shouldShowNotFoundPage} | ||
subtitleKey="notFound.noAccess" | ||
subtitleKey={shouldShowNotFoundLinkedAction ? '' : 'notFound.noAccess'} | ||
shouldShowBackButton={shouldUseNarrowLayout} | ||
onBackButtonPress={Navigation.goBack} | ||
shouldShowLink={false} | ||
onBackButtonPress={shouldShowNotFoundLinkedAction ? navigateToEndOfReport : Navigation.goBack} | ||
shouldShowLink={shouldShowNotFoundLinkedAction} | ||
linkKey="notFound.noAccess" | ||
onLinkPress={navigateToEndOfReport} | ||
> | ||
<OfflineWithFeedback | ||
pendingAction={reportPendingAction} | ||
|
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.
If we keep render the text even though subtitle is empty, an extra space can be seen.