From 7503d769181e0f325db5ad7d82b5917727a5e455 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 28 May 2024 04:35:21 +0700 Subject: [PATCH 1/7] fix Deeplinking to a whisper results in hmm it is not here page --- src/pages/home/ReportScreen.tsx | 19 +++++++++++++++---- src/types/onyx/ReportAction.ts | 2 ++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index a1e375651c31..ad0fbb93cc35 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -28,6 +28,7 @@ import usePrevious from '@hooks/usePrevious'; import useThemeStyles from '@hooks/useThemeStyles'; import useViewportOffsetTop from '@hooks/useViewportOffsetTop'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import {getCurrentUserAccountID} from '@libs/actions/Report'; import Timing from '@libs/actions/Timing'; import Navigation from '@libs/Navigation/Navigation'; import clearReportNotifications from '@libs/Notification/clearReportNotifications'; @@ -625,15 +626,25 @@ function ReportScreen({ fetchReport(); }, [fetchReport]); - const isLinkedReportActionDeleted = useMemo(() => { + const {isLinkedReportActionDeleted, isInaccessibleWhisper} = useMemo(() => { + const currentUserAccountID = getCurrentUserAccountID(); if (!reportActionIDFromRoute || !sortedAllReportActions) { - return false; + return {isLinkedReportActionDeleted: false, isInaccessibleWhisper: false}; } const action = sortedAllReportActions.find((item) => item.reportActionID === reportActionIDFromRoute); - return action && !ReportActionsUtils.shouldReportActionBeVisible(action, action.reportActionID); + return { + isLinkedReportActionDeleted: action && !ReportActionsUtils.shouldReportActionBeVisible(action, action.reportActionID), + isInaccessibleWhisper: ReportActionsUtils.isWhisperAction(action) && !(action?.whisperedToAccountIDs ?? []).includes(currentUserAccountID), + }; }, [reportActionIDFromRoute, sortedAllReportActions]); - if (isLinkedReportActionDeleted ?? (!shouldShowSkeleton && reportActionIDFromRoute && reportActions?.length === 0 && !isLinkingToMessage)) { + useEffect(() => { + if (isInaccessibleWhisper) { + Navigation.setParams({reportActionID: ''}); + } + }, [isInaccessibleWhisper]); + + if ((!isInaccessibleWhisper && isLinkedReportActionDeleted) ?? (!shouldShowSkeleton && reportActionIDFromRoute && reportActions?.length === 0 && !isLinkingToMessage)) { return ( ; type ReportAction = ReportActionBase & OriginalMessage; From 7d0e6fa538f4992dd3104e0e3ed2dfe5bb5278bd Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 28 May 2024 04:47:11 +0700 Subject: [PATCH 2/7] fix lint --- src/pages/home/ReportScreen.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index ad0fbb93cc35..5f1867ef8473 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -639,9 +639,10 @@ function ReportScreen({ }, [reportActionIDFromRoute, sortedAllReportActions]); useEffect(() => { - if (isInaccessibleWhisper) { - Navigation.setParams({reportActionID: ''}); + if (!isInaccessibleWhisper) { + return; } + Navigation.setParams({reportActionID: ''}); }, [isInaccessibleWhisper]); if ((!isInaccessibleWhisper && isLinkedReportActionDeleted) ?? (!shouldShowSkeleton && reportActionIDFromRoute && reportActions?.length === 0 && !isLinkingToMessage)) { From f4372a135323f01c504a2d7256b9ec87df526bea Mon Sep 17 00:00:00 2001 From: tienifr Date: Fri, 31 May 2024 18:43:41 +0700 Subject: [PATCH 3/7] fix lint --- src/pages/home/ReportScreen.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index d5af2aefb66e..60bf4e6613de 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -625,7 +625,7 @@ function ReportScreen({ const action = sortedAllReportActions.find((item) => item.reportActionID === reportActionIDFromRoute); return { isLinkedReportActionDeleted: action && !ReportActionsUtils.shouldReportActionBeVisible(action, action.reportActionID), - isInaccessibleWhisper: ReportActionsUtils.isWhisperAction(action) && !(action?.whisperedToAccountIDs ?? []).includes(currentUserAccountID), + isInaccessibleWhisper: action && ReportActionsUtils.isWhisperAction(action) && !(action?.whisperedToAccountIDs ?? []).includes(currentUserAccountID), }; }, [reportActionIDFromRoute, sortedAllReportActions]); From d023849062976c9f7079cb9fd75c2dff07b52f1b Mon Sep 17 00:00:00 2001 From: tienifr Date: Sun, 2 Jun 2024 16:23:07 +0700 Subject: [PATCH 4/7] fix url param does not reset --- src/pages/home/ReportScreen.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 60bf4e6613de..66356cd31334 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -633,7 +633,9 @@ function ReportScreen({ if (!isInaccessibleWhisper) { return; } - Navigation.setParams({reportActionID: ''}); + Navigation.isNavigationReady().then(() => { + Navigation.setParams({reportActionID: ''}); + }); }, [isInaccessibleWhisper]); if ((!isInaccessibleWhisper && isLinkedReportActionDeleted) ?? (!shouldShowSkeleton && reportActionIDFromRoute && reportActions?.length === 0 && !isLinkingToMessage)) { From 0c700f551f6f218278ab317418d8c6864257a156 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 4 Jun 2024 02:37:39 +0700 Subject: [PATCH 5/7] fix add prop comment --- src/types/onyx/ReportAction.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index 92b6d5649db9..bca1befff1b8 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -231,6 +231,7 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** The admins's ID */ adminAccountID?: number; + /** These are the account IDs to whom a message was whispered. It allow sending a message that is only visible to certain users. */ whisperedToAccountIDs?: number[]; }>; From 648b74f0650daa9dd117603a7d5c27c17d7aa86e Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 6 Jun 2024 17:46:53 +0700 Subject: [PATCH 6/7] fix add comment --- src/pages/home/ReportScreen.tsx | 2 ++ src/types/onyx/ReportAction.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 1dc6778a0b2d..56edd6b590c2 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -631,6 +631,8 @@ function ReportScreen({ }; }, [reportActionIDFromRoute, sortedAllReportActions]); + // 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(() => { if (!isInaccessibleWhisper) { return; diff --git a/src/types/onyx/ReportAction.ts b/src/types/onyx/ReportAction.ts index bca1befff1b8..cb11e468754c 100644 --- a/src/types/onyx/ReportAction.ts +++ b/src/types/onyx/ReportAction.ts @@ -231,7 +231,7 @@ type ReportActionBase = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** The admins's ID */ adminAccountID?: number; - /** These are the account IDs to whom a message was whispered. It allow sending a message that is only visible to certain users. */ + /** These are the account IDs to whom a message was whispered. It is used to check if a specific user should be displayed a whisper message or not. */ whisperedToAccountIDs?: number[]; }>; From b020a2e92c9c22a7b6a1a9d50369e8b06f08627b Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 6 Jun 2024 17:48:24 +0700 Subject: [PATCH 7/7] fix add comment --- src/pages/home/ReportScreen.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 56edd6b590c2..826d6b0fbdc1 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -631,8 +631,8 @@ function ReportScreen({ }; }, [reportActionIDFromRoute, sortedAllReportActions]); - // 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". + // 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(() => { if (!isInaccessibleWhisper) { return;