Skip to content

Commit

Permalink
Merge pull request #38488 from software-mansion-labs/fix/delete-works…
Browse files Browse the repository at this point in the history
…pace-not-found

Fix showing not found page after deleting a workspace
  • Loading branch information
pecanoro authored Mar 21, 2024
2 parents fb344de + d8184b4 commit 34731fe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pages/workspace/WorkspacePageWithSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -143,7 +145,11 @@ function WorkspacePageWithSections({
return true;
}

return (!isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy) && !shouldShowNonAdmin) || PolicyUtils.isPendingDeletePolicy(policy);
// 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]);

Expand Down

0 comments on commit 34731fe

Please sign in to comment.