From f960ccc76caa5fba636e9023d5bba45fef1d205a Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Mon, 18 Mar 2024 15:06:27 +0100 Subject: [PATCH 1/3] Fix shouldShow in WorkspacePageWithSections --- src/pages/workspace/WorkspacePageWithSections.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 4904a4f35193..0adf14917f7e 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -143,7 +143,7 @@ function WorkspacePageWithSections({ return true; } - return (!isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy) && !shouldShowNonAdmin) || PolicyUtils.isPendingDeletePolicy(policy); + return (!isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy) && !shouldShowNonAdmin); // eslint-disable-next-line react-hooks/exhaustive-deps }, [policy, shouldShowNonAdmin]); From 7782d5e815d1603ae433c69b59c91a39de327e4e Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Mon, 18 Mar 2024 18:34:51 +0100 Subject: [PATCH 2/3] Run prettier --- src/pages/workspace/WorkspacePageWithSections.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 0adf14917f7e..5b65a0242f83 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -143,7 +143,7 @@ function WorkspacePageWithSections({ return true; } - return (!isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy) && !shouldShowNonAdmin); + return !isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy) && !shouldShowNonAdmin; // eslint-disable-next-line react-hooks/exhaustive-deps }, [policy, shouldShowNonAdmin]); From d8184b4b2f817c915cf636a6285afd500f713f62 Mon Sep 17 00:00:00 2001 From: Wojciech Boman Date: Wed, 20 Mar 2024 21:33:57 +0100 Subject: [PATCH 3/3] Fix showing not found page after deleting workspace --- src/pages/workspace/WorkspacePageWithSections.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 5b65a0242f83..244b9f85b79a 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -10,6 +10,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import ScrollViewWithContext from '@components/ScrollViewWithContext'; import useNetwork from '@hooks/useNetwork'; +import usePrevious from '@hooks/usePrevious'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; import BankAccount from '@libs/models/BankAccount'; @@ -127,6 +128,7 @@ function WorkspacePageWithSections({ const {isSmallScreenWidth} = useWindowDimensions(); const firstRender = useRef(true); const isFocused = useIsFocused(); + const prevPolicy = usePrevious(policy); useEffect(() => { // Because isLoading is false before merging in Onyx, we need firstRender ref to display loading page as well before isLoading is change to true @@ -143,7 +145,11 @@ function WorkspacePageWithSections({ return true; } - return !isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy) && !shouldShowNonAdmin; + // We check isPendingDelete for both policy and prevPolicy to prevent the NotFound view from showing right after we delete the workspace + return ( + (!isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy) && !shouldShowNonAdmin) || + (PolicyUtils.isPendingDeletePolicy(policy) && PolicyUtils.isPendingDeletePolicy(prevPolicy)) + ); // eslint-disable-next-line react-hooks/exhaustive-deps }, [policy, shouldShowNonAdmin]);