-
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 here page shows up briefly when deleting the expense while it is highlighted #56153
Changes from 3 commits
19f0d68
146b89e
72da601
cd542fd
d036c02
259e04c
6f20fd0
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 |
---|---|---|
|
@@ -386,7 +386,13 @@ function ReportScreen({route, navigation}: ReportScreenProps) { | |
() => !!linkedAction && !shouldReportActionBeVisible(linkedAction, linkedAction.reportActionID, canUserPerformWriteAction(report)), | ||
[linkedAction, report], | ||
); | ||
const prevIsLinkedActionDeleted = usePrevious(linkedAction ? isLinkedActionDeleted : undefined); | ||
|
||
const previsLinkedActionDeleted = usePrevious(linkedAction ? isLinkedActionDeleted : undefined); | ||
|
||
const lastReportActionIDFromRoute = usePrevious(reportActionIDFromRoute); | ||
|
||
const [isNavigatingToAction, setIsNavigatingToAction] = useState(false); | ||
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.
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. you're right, it's updated to isNavigatingToDeletedAction, makes more sense. |
||
|
||
const isLinkedActionInaccessibleWhisper = useMemo( | ||
() => !!linkedAction && isWhisperAction(linkedAction) && !(linkedAction?.whisperedToAccountIDs ?? []).includes(currentUserAccountID), | ||
[currentUserAccountID, linkedAction], | ||
|
@@ -416,11 +422,9 @@ function ReportScreen({route, navigation}: ReportScreenProps) { | |
(!!deleteTransactionNavigateBackUrl && getReportIDFromLink(deleteTransactionNavigateBackUrl) === report?.reportID) || | ||
(!reportMetadata.isOptimisticReport && isLoading); | ||
|
||
const isLinkedActionBecomesDeleted = prevIsLinkedActionDeleted !== undefined && !prevIsLinkedActionDeleted && isLinkedActionDeleted; | ||
|
||
// eslint-disable-next-line rulesdir/no-negated-variables | ||
const shouldShowNotFoundLinkedAction = | ||
(!isLinkedActionInaccessibleWhisper && isLinkedActionDeleted && !isLinkedActionBecomesDeleted) || | ||
(!isLinkedActionInaccessibleWhisper && isLinkedActionDeleted && isNavigatingToAction) || | ||
(shouldShowSkeleton && | ||
!reportMetadata.isLoadingInitialReportActions && | ||
!!reportActionIDFromRoute && | ||
|
@@ -735,13 +739,23 @@ function ReportScreen({route, navigation}: ReportScreenProps) { | |
}, [fetchReport]); | ||
|
||
useEffect(() => { | ||
// If the linked action is previously available but now deleted, | ||
// remove the reportActionID from the params to not link to the deleted action. | ||
if (!isLinkedActionBecomesDeleted) { | ||
// Only handle deletion cases when there's a deleted action | ||
if (!isLinkedActionDeleted) { | ||
setIsNavigatingToAction(false); | ||
return; | ||
} | ||
Navigation.setParams({reportActionID: ''}); | ||
}, [isLinkedActionBecomesDeleted]); | ||
|
||
// Set navigation state when user clicks a deleted Action link | ||
if (lastReportActionIDFromRoute !== reportActionIDFromRoute) { | ||
setIsNavigatingToAction(true); | ||
return; | ||
} | ||
|
||
// Clear params when Action gets deleted while heighlighted | ||
if (!isNavigatingToAction && previsLinkedActionDeleted === false) { | ||
Navigation.setParams({reportActionID: ''}); | ||
} | ||
}, [isLinkedActionDeleted, previsLinkedActionDeleted, lastReportActionIDFromRoute, reportActionIDFromRoute, isNavigatingToAction]); | ||
|
||
// 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". | ||
|
@@ -775,7 +789,6 @@ function ReportScreen({route, navigation}: ReportScreenProps) { | |
!isDeletedAction(mostRecentReportAction); | ||
|
||
const lastRoute = usePrevious(route); | ||
const lastReportActionIDFromRoute = usePrevious(reportActionIDFromRoute); | ||
|
||
const onComposerFocus = useCallback(() => setIsComposerFocus(true), []); | ||
const onComposerBlur = useCallback(() => setIsComposerFocus(false), []); | ||
|
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.
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.
fixed!