From cd48cd5f50f60c908b6df795ebd294b8fe61e20b Mon Sep 17 00:00:00 2001 From: truph01 Date: Mon, 3 Jun 2024 16:43:48 +0700 Subject: [PATCH 1/4] Fix: OpenWorkspaceView API call is made on pages that do not need it --- src/pages/workspace/WorkspacePageWithSections.tsx | 2 +- src/pages/workspace/WorkspaceProfilePage.tsx | 1 + src/pages/workspace/bills/WorkspaceBillsPage.tsx | 1 + src/pages/workspace/card/WorkspaceCardPage.tsx | 1 + src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx | 1 + .../reimburse/WorkspaceRateAndUnitPage/InitialPage.tsx | 1 - .../workspace/reimburse/WorkspaceRateAndUnitPage/RatePage.tsx | 1 - .../workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage.tsx | 1 - src/pages/workspace/reimburse/WorkspaceReimbursePage.tsx | 1 - src/pages/workspace/travel/WorkspaceTravelPage.tsx | 1 + src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx | 1 - 11 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 58288f213818e..738a0663b94be 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -106,7 +106,7 @@ function WorkspacePageWithSections({ reimbursementAccount = CONST.REIMBURSEMENT_ACCOUNT.DEFAULT_DATA, route, shouldUseScrollView = false, - shouldSkipVBBACall = false, + shouldSkipVBBACall = true, shouldShowBackButton = false, user, shouldShowLoading = true, diff --git a/src/pages/workspace/WorkspaceProfilePage.tsx b/src/pages/workspace/WorkspaceProfilePage.tsx index be6143ff62407..4d9ed3e138fd4 100644 --- a/src/pages/workspace/WorkspaceProfilePage.tsx +++ b/src/pages/workspace/WorkspaceProfilePage.tsx @@ -125,6 +125,7 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi shouldShowOfflineIndicatorInWideScreen shouldShowNonAdmin icon={Illustrations.House} + shouldSkipVBBACall={false} > {(hasVBA?: boolean) => ( diff --git a/src/pages/workspace/bills/WorkspaceBillsPage.tsx b/src/pages/workspace/bills/WorkspaceBillsPage.tsx index 9e1810d747937..cdd733d591412 100644 --- a/src/pages/workspace/bills/WorkspaceBillsPage.tsx +++ b/src/pages/workspace/bills/WorkspaceBillsPage.tsx @@ -23,6 +23,7 @@ function WorkspaceBillsPage({route}: WorkspaceBillsPageProps) { shouldUseScrollView headerText={translate('workspace.common.bills')} route={route} + shouldSkipVBBACall={false} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_BILLS} shouldShowOfflineIndicatorInWideScreen > diff --git a/src/pages/workspace/card/WorkspaceCardPage.tsx b/src/pages/workspace/card/WorkspaceCardPage.tsx index eeec0edf106b1..c79a335376d6f 100644 --- a/src/pages/workspace/card/WorkspaceCardPage.tsx +++ b/src/pages/workspace/card/WorkspaceCardPage.tsx @@ -24,6 +24,7 @@ function WorkspaceCardPage({route}: WorkspaceCardPageProps) { shouldUseScrollView headerText={translate('workspace.common.card')} route={route} + shouldSkipVBBACall={false} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_CARD} shouldShowOfflineIndicatorInWideScreen > diff --git a/src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx b/src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx index ef0a73788dfa2..f1a973d5c47d2 100644 --- a/src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx +++ b/src/pages/workspace/invoices/WorkspaceInvoicesPage.tsx @@ -23,6 +23,7 @@ function WorkspaceInvoicesPage({route}: WorkspaceInvoicesPageProps) { headerText={translate('workspace.common.invoices')} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_INVOICES} shouldShowOfflineIndicatorInWideScreen + shouldSkipVBBACall={false} route={route} > {(hasVBA?: boolean, policyID?: string) => ( diff --git a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/InitialPage.tsx b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/InitialPage.tsx index 6faf23af289e4..b99157b0231a2 100644 --- a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/InitialPage.tsx +++ b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/InitialPage.tsx @@ -100,7 +100,6 @@ function WorkspaceRateAndUnitPage(props: WorkspaceRateAndUnitPageProps) { headerText={translate('workspace.reimburse.trackDistance')} route={props.route} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE} - shouldSkipVBBACall backButtonRoute="" shouldShowLoading={false} shouldShowBackButton diff --git a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage.tsx b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage.tsx index 9c7eaa82167f4..52fc35db59d68 100644 --- a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage.tsx +++ b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/RatePage.tsx @@ -63,7 +63,6 @@ function WorkspaceRatePage(props: WorkspaceRatePageProps) { headerText={translate('workspace.reimburse.trackDistanceRate')} route={props.route} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE} - shouldSkipVBBACall backButtonRoute={ROUTES.WORKSPACE_RATE_AND_UNIT.getRoute(props.policy?.id ?? '')} shouldShowLoading={false} shouldShowBackButton diff --git a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage.tsx b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage.tsx index 92d76b4a33c62..8580b112c8db5 100644 --- a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage.tsx +++ b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage/UnitPage.tsx @@ -51,7 +51,6 @@ function WorkspaceUnitPage(props: WorkspaceUnitPageProps) { headerText={translate('workspace.reimburse.trackDistanceUnit')} route={props.route} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE} - shouldSkipVBBACall backButtonRoute={ROUTES.WORKSPACE_RATE_AND_UNIT.getRoute(props.policy?.id ?? '')} shouldShowLoading={false} shouldShowBackButton diff --git a/src/pages/workspace/reimburse/WorkspaceReimbursePage.tsx b/src/pages/workspace/reimburse/WorkspaceReimbursePage.tsx index 6bb15a8a17ce4..d929ec10748a4 100644 --- a/src/pages/workspace/reimburse/WorkspaceReimbursePage.tsx +++ b/src/pages/workspace/reimburse/WorkspaceReimbursePage.tsx @@ -20,7 +20,6 @@ function WorkspaceReimbursePage({route, policy}: WorkspaceReimbursePageProps) { headerText={translate('workspace.common.reimburse')} route={route} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE} - shouldSkipVBBACall shouldShowLoading={false} shouldShowOfflineIndicatorInWideScreen > diff --git a/src/pages/workspace/travel/WorkspaceTravelPage.tsx b/src/pages/workspace/travel/WorkspaceTravelPage.tsx index 1acae9e6d359a..eb61397d10b29 100644 --- a/src/pages/workspace/travel/WorkspaceTravelPage.tsx +++ b/src/pages/workspace/travel/WorkspaceTravelPage.tsx @@ -25,6 +25,7 @@ function WorkspaceTravelPage({route}: WorkspaceTravelPageProps) { route={route} guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_TRAVEL} shouldShowOfflineIndicatorInWideScreen + shouldSkipVBBACall={false} > {(hasVBA, policyID) => ( diff --git a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx index 5b17a4e26051e..a008f89df50e7 100644 --- a/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx +++ b/src/pages/workspace/workflows/WorkspaceWorkflowsPage.tsx @@ -288,7 +288,6 @@ function WorkspaceWorkflowsPage({policy, betas, route}: WorkspaceWorkflowsPagePr guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_WORKFLOWS} shouldShowOfflineIndicatorInWideScreen shouldShowNotFoundPage={!isPaidGroupPolicy || !isPolicyAdmin} - shouldSkipVBBACall isLoading={isLoading} shouldShowLoading={isLoading} shouldUseScrollView From 0011a1cb078c59d917763bea7d46eca7ca3f6769 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 7 Jun 2024 09:00:07 +0700 Subject: [PATCH 2/4] Fix: only call VBBA one time --- src/pages/workspace/WorkspacePageWithSections.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 738a0663b94be..3476f67487909 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -129,17 +129,20 @@ function WorkspacePageWithSections({ const firstRender = useRef(true); const isFocused = useIsFocused(); const prevPolicy = usePrevious(policy); + const isCalledVBBA = useRef(false); 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 firstRender.current = false; }, []); - useFocusEffect( - useCallback(() => { - fetchData(policyID, shouldSkipVBBACall); - }, [policyID, shouldSkipVBBACall]), - ); + useEffect(() => { + if (isCalledVBBA.current) { + return; + } + isCalledVBBA.current = true; + fetchData(policyID, shouldSkipVBBACall); + }, [policyID, shouldSkipVBBACall]); const shouldShow = useMemo(() => { // If the policy object doesn't exist or contains only error data, we shouldn't display it. From 7951fcf44313156b4880274654f17c4e9e5404df Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 7 Jun 2024 09:05:46 +0700 Subject: [PATCH 3/4] fix rename ref --- src/pages/workspace/WorkspacePageWithSections.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 3476f67487909..dab0294359233 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -129,7 +129,7 @@ function WorkspacePageWithSections({ const firstRender = useRef(true); const isFocused = useIsFocused(); const prevPolicy = usePrevious(policy); - const isCalledVBBA = useRef(false); + const isCalledVBBARef = useRef(false); 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 @@ -137,10 +137,10 @@ function WorkspacePageWithSections({ }, []); useEffect(() => { - if (isCalledVBBA.current) { + if (isCalledVBBARef.current || !policyID) { return; } - isCalledVBBA.current = true; + isCalledVBBARef.current = true; fetchData(policyID, shouldSkipVBBACall); }, [policyID, shouldSkipVBBACall]); From 6b8c4b2e62ffc262671616467d42c4e44adc8fee Mon Sep 17 00:00:00 2001 From: truph01 Date: Sat, 8 Jun 2024 08:02:32 +0700 Subject: [PATCH 4/4] Fix: Remove isCalledVBBARef --- src/pages/workspace/WorkspacePageWithSections.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index dab0294359233..738a0663b94be 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -129,20 +129,17 @@ function WorkspacePageWithSections({ const firstRender = useRef(true); const isFocused = useIsFocused(); const prevPolicy = usePrevious(policy); - const isCalledVBBARef = useRef(false); 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 firstRender.current = false; }, []); - useEffect(() => { - if (isCalledVBBARef.current || !policyID) { - return; - } - isCalledVBBARef.current = true; - fetchData(policyID, shouldSkipVBBACall); - }, [policyID, shouldSkipVBBACall]); + useFocusEffect( + useCallback(() => { + fetchData(policyID, shouldSkipVBBACall); + }, [policyID, shouldSkipVBBACall]), + ); const shouldShow = useMemo(() => { // If the policy object doesn't exist or contains only error data, we shouldn't display it.