Skip to content

Commit 615f6d1

Browse files
authored
Merge pull request Expensify#68589 from FitseTLT/fix-QBD-bug-of-considering-small-screen-as-mweb
Fix - Accounting - Resizing the window on the QBD setup page should not trigger any error
2 parents 5f45065 + 1d51905 commit 615f6d1

3 files changed

Lines changed: 11 additions & 15 deletions

File tree

src/components/ConnectToQuickbooksDesktopFlow/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import {useEffect} from 'react';
2-
import useResponsiveLayout from '@hooks/useResponsiveLayout';
2+
import {isMobile} from '@libs/Browser';
33
import Navigation from '@libs/Navigation/Navigation';
44
import ROUTES from '@src/ROUTES';
55
import type {ConnectToQuickbooksDesktopFlowProps} from './types';
66

7-
function ConnectToQuickbooksDesktopFlow({policyID}: ConnectToQuickbooksDesktopFlowProps) {
8-
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
9-
const {isSmallScreenWidth} = useResponsiveLayout();
7+
const isMobileWeb = isMobile();
108

9+
function ConnectToQuickbooksDesktopFlow({policyID}: ConnectToQuickbooksDesktopFlowProps) {
1110
useEffect(() => {
12-
if (isSmallScreenWidth) {
11+
if (isMobileWeb) {
1312
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL.getRoute(policyID));
1413
} else {
1514
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_MODAL.getRoute(policyID));
1615
}
17-
}, [isSmallScreenWidth, policyID]);
16+
}, [policyID]);
1817

1918
return null;
2019
}

src/pages/workspace/accounting/AccountingContext.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type {View} from 'react-native';
44
import type {OnyxEntry} from 'react-native-onyx';
55
import AccountingConnectionConfirmationModal from '@components/AccountingConnectionConfirmationModal';
66
import useLocalize from '@hooks/useLocalize';
7-
import useResponsiveLayout from '@hooks/useResponsiveLayout';
87
import {removePolicyConnection} from '@libs/actions/connections';
98
import Navigation from '@libs/Navigation/Navigation';
109
import {isControlPolicy} from '@libs/PolicyUtils';
@@ -61,10 +60,6 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
6160
const {translate} = useLocalize();
6261
const policyID = policy?.id;
6362

64-
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to allow QuickBooks Desktop setup to be shown only on large screens
65-
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
66-
const {isSmallScreenWidth} = useResponsiveLayout();
67-
6863
const startIntegrationFlow = React.useCallback(
6964
(newActiveIntegration: ActiveIntegration) => {
7065
if (!policyID) {
@@ -80,7 +75,6 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
8075
newActiveIntegration.integrationToDisconnect,
8176
newActiveIntegration.shouldDisconnectIntegrationBeforeConnecting,
8277
undefined,
83-
isSmallScreenWidth,
8478
);
8579
const workspaceUpgradeNavigationDetails = accountingIntegrationData?.workspaceUpgradeNavigationDetails;
8680
if (workspaceUpgradeNavigationDetails && !isControlPolicy(policy)) {
@@ -94,7 +88,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
9488
key: Math.random(),
9589
});
9690
},
97-
[isSmallScreenWidth, policy, policyID, translate],
91+
[policy, policyID, translate],
9892
);
9993

10094
const closeConfirmationModal = () => {

src/pages/workspace/accounting/utils.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Text from '@components/Text';
1111
import TextLink from '@components/TextLink';
1212
import {isAuthenticationError} from '@libs/actions/connections';
1313
import {getAdminPoliciesConnectedToSageIntacct} from '@libs/actions/Policy/Policy';
14+
import getPlatform from '@libs/getPlatform';
1415
import {translateLocal} from '@libs/Localize';
1516
import {canUseTaxNetSuite} from '@libs/PolicyUtils';
1617
import Navigation from '@navigation/Navigation';
@@ -39,6 +40,9 @@ import {
3940
} from './netsuite/utils';
4041
import type {AccountingIntegration} from './types';
4142

43+
const platform = getPlatform(true);
44+
const isMobile = [CONST.PLATFORM.MOBILE_WEB, CONST.PLATFORM.IOS, CONST.PLATFORM.ANDROID].some((value) => value === platform);
45+
4246
function getAccountingIntegrationData(
4347
connectionName: PolicyConnectionName,
4448
policyID: string,
@@ -48,7 +52,6 @@ function getAccountingIntegrationData(
4852
integrationToDisconnect?: ConnectionName,
4953
shouldDisconnectIntegrationBeforeConnecting?: boolean,
5054
canUseNetSuiteUSATax?: boolean,
51-
isSmallScreenWidth?: boolean,
5255
): AccountingIntegration | undefined {
5356
const qboConfig = policy?.connections?.quickbooksOnline?.config;
5457
const netsuiteConfig = policy?.connections?.netsuite?.options?.config;
@@ -68,7 +71,7 @@ function getAccountingIntegrationData(
6871
if (integrationToDisconnect) {
6972
return ROUTES.POLICY_ACCOUNTING.getRoute(policyID, connectionName, integrationToDisconnect, shouldDisconnectIntegrationBeforeConnecting);
7073
}
71-
if (isSmallScreenWidth) {
74+
if (isMobile) {
7275
return ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL.getRoute(policyID);
7376
}
7477
return ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_MODAL.getRoute(policyID);

0 commit comments

Comments
 (0)