Skip to content
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4333,6 +4333,7 @@ const translations = {
goToODToSettings: 'Go to Expensify Classic to manage your settings.',
setup: 'Connect',
lastSync: ({relativeDate}: LastSyncAccountingParams) => `Last synced ${relativeDate}`,
notSync: 'Not synced',
import: 'Import',
export: 'Export',
advanced: 'Advanced',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4345,6 +4345,7 @@ const translations = {
goToODToSettings: 'Ve a Expensify Classic para gestionar tus configuraciones.',
setup: 'Configurar',
lastSync: ({relativeDate}: LastSyncAccountingParams) => `Recién sincronizado ${relativeDate}`,
notSync: 'No sincronizado',
import: 'Importar',
export: 'Exportar',
advanced: 'Avanzado',
Expand Down
27 changes: 17 additions & 10 deletions src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ type RouteParams = {
};

function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`);
const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID}`);
const [conciergeChatReportID] = useOnyx(ONYXKEYS.DERIVED.CONCIERGE_CHAT_REPORT_ID);
const workspaceAccountID = policy?.workspaceAccountID ?? CONST.DEFAULT_NUMBER_ID;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this needs to be defined separately?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s77rt I got this ESlint error when running pipeline.

const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`, {canBeMissing: true});
const [cardSettings] = useOnyx(`${ONYXKEYS.COLLECTION.PRIVATE_EXPENSIFY_CARD_SETTINGS}${workspaceAccountID}`, {canBeMissing: true});
const [conciergeChatReportID] = useOnyx(ONYXKEYS.DERIVED.CONCIERGE_CHAT_REPORT_ID, {canBeMissing: true});
const theme = useTheme();
const styles = useThemeStyles();
const {translate, datetimeToRelative: getDatetimeToRelative} = useLocalize();
Expand All @@ -81,7 +82,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
const [datetimeToRelative, setDateTimeToRelative] = useState('');
const threeDotsMenuContainerRef = useRef<View>(null);
const {startIntegrationFlow, popoverAnchorRefs} = useAccountingContext();
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: false});
const {isLargeScreenWidth} = useResponsiveLayout();
const route = useRoute();
const params = route.params as RouteParams | undefined;
Expand Down Expand Up @@ -329,10 +330,19 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
if (!connectedIntegration || !policyID) {
return [];
}
const shouldHideConfigurationOptions = isConnectionUnverified(policy, connectedIntegration);
const isConnectionVerified = !isConnectionUnverified(policy, connectedIntegration);
const integrationData = getAccountingIntegrationData(connectedIntegration, policyID, translate, policy, undefined, undefined, undefined, canUseNetSuiteUSATax);
const iconProps = integrationData?.icon ? {icon: integrationData.icon, iconType: CONST.ICON_TYPE_AVATAR} : {};

let connectionMessage;
if (isSyncInProgress && connectionSyncProgress?.stageInProgress) {
connectionMessage = translate('workspace.accounting.connections.syncStageName', {stage: connectionSyncProgress?.stageInProgress});
} else if (!isConnectionVerified) {
connectionMessage = translate('workspace.accounting.notSync');
} else {
connectionMessage = translate('workspace.accounting.lastSync', {relativeDate: datetimeToRelative});
}

const configurationOptions = [
{
icon: Expensicons.Pencil,
Expand Down Expand Up @@ -391,10 +401,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
errorText: synchronizationError,
errorTextStyle: [styles.mt5],
shouldShowRedDotIndicator: true,
description:
isSyncInProgress && connectionSyncProgress?.stageInProgress
? translate('workspace.accounting.connections.syncStageName', {stage: connectionSyncProgress.stageInProgress})
: translate('workspace.accounting.lastSync', {relativeDate: datetimeToRelative}),
description: connectionMessage,
rightComponent: isSyncInProgress ? (
<ActivityIndicator
style={[styles.popoverMenuIcon]}
Expand All @@ -414,7 +421,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) {
),
},
...(isEmptyObject(integrationSpecificMenuItems) || shouldShowSynchronizationError || isEmptyObject(policy?.connections) ? [] : [integrationSpecificMenuItems]),
...(isEmptyObject(policy?.connections) || shouldHideConfigurationOptions ? [] : configurationOptions),
...(isEmptyObject(policy?.connections) || !isConnectionVerified ? [] : configurationOptions),
];
}, [
policy,
Expand Down
13 changes: 7 additions & 6 deletions src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ import useSearchBackPress from '@hooks/useSearchBackPress';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useThreeDotsAnchorPosition from '@hooks/useThreeDotsAnchorPosition';
import {isConnectionInProgress} from '@libs/actions/connections';
import {isConnectionInProgress, isConnectionUnverified} from '@libs/actions/connections';
import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
import localeCompare from '@libs/LocaleCompare';
import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types';
import {getCurrentConnectionName, hasAccountingConnections, shouldShowSyncError} from '@libs/PolicyUtils';
import {getConnectedIntegration, getCurrentConnectionName, hasAccountingConnections, shouldShowSyncError} from '@libs/PolicyUtils';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import {close} from '@userActions/Modal';
import {clearCategoryErrors, deleteWorkspaceCategories, downloadCategoriesCSV, openPolicyCategoriesPage, setWorkspaceCategoryEnabled} from '@userActions/Policy/Category';
Expand Down Expand Up @@ -79,11 +79,12 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
const backTo = route.params?.backTo;
const policy = usePolicy(policyId);
const {selectionMode} = useMobileSelectionMode();
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyId}`);
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`);
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyId}`, {canBeMissing: true});
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`, {canBeMissing: true});
const isSyncInProgress = isConnectionInProgress(connectionSyncProgress, policy);
const hasSyncError = shouldShowSyncError(policy, isSyncInProgress);
const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0;
const connectedIntegration = getConnectedIntegration(policy) ?? connectionSyncProgress?.connectionName;
const isConnectionVerified = connectedIntegration && !isConnectionUnverified(policy, connectedIntegration);
const currentConnectionName = getCurrentConnectionName(policy);
const isQuickSettingsFlow = !!backTo;
const {canUseLeftHandBar} = usePermissions();
Expand Down Expand Up @@ -337,7 +338,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {

const getHeaderText = () => (
<View style={[styles.ph5, styles.pb5, styles.pt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{!hasSyncError && isConnectedToAccounting ? (
{!hasSyncError && isConnectionVerified ? (
<Text>
<Text style={[styles.textNormal, styles.colorMuted]}>{`${translate('workspace.categories.importedFromAccountingSoftware')} `}</Text>
<TextLink
Expand Down
11 changes: 6 additions & 5 deletions src/pages/workspace/reportFields/WorkspaceReportFieldsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ import usePolicy from '@hooks/usePolicy';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {isConnectionInProgress} from '@libs/actions/connections';
import {isConnectionInProgress, isConnectionUnverified} from '@libs/actions/connections';
import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
import localeCompare from '@libs/LocaleCompare';
import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types';
import {getCurrentConnectionName, hasAccountingConnections, shouldShowSyncError} from '@libs/PolicyUtils';
import {getConnectedIntegration, getCurrentConnectionName, hasAccountingConnections, shouldShowSyncError} from '@libs/PolicyUtils';
import {getReportFieldKey} from '@libs/ReportUtils';
import {getReportFieldTypeTranslationKey} from '@libs/WorkspaceReportFieldUtils';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
Expand Down Expand Up @@ -84,10 +84,11 @@ function WorkspaceReportFieldsPage({
const [selectedReportFields, setSelectedReportFields] = useState<PolicyReportField[]>([]);
const [deleteReportFieldsConfirmModalVisible, setDeleteReportFieldsConfirmModalVisible] = useState(false);
const hasReportAccountingConnections = hasAccountingConnections(policy);
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`);
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`, {canBeMissing: true});
const isSyncInProgress = isConnectionInProgress(connectionSyncProgress, policy);
const hasSyncError = shouldShowSyncError(policy, isSyncInProgress);
const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0;
const connectedIntegration = getConnectedIntegration(policy) ?? connectionSyncProgress?.connectionName;
const isConnectionVerified = connectedIntegration && !isConnectionUnverified(policy, connectedIntegration);
const currentConnectionName = getCurrentConnectionName(policy);

const canSelectMultiple = !hasReportAccountingConnections && (isSmallScreenWidth ? selectionMode?.isEnabled : true);
Expand Down Expand Up @@ -214,7 +215,7 @@ function WorkspaceReportFieldsPage({

const getHeaderText = () => (
<View style={[styles.ph5, styles.pb5, styles.pt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{!hasSyncError && isConnectedToAccounting ? (
{!hasSyncError && isConnectionVerified ? (
<Text>
<Text style={[styles.textNormal, styles.colorMuted]}>{`${translate('workspace.reportFields.importedFromAccountingSoftware')} `}</Text>
<TextLink
Expand Down
12 changes: 7 additions & 5 deletions src/pages/workspace/tags/WorkspaceTagsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import useSearchBackPress from '@hooks/useSearchBackPress';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useThreeDotsAnchorPosition from '@hooks/useThreeDotsAnchorPosition';
import {isConnectionInProgress} from '@libs/actions/connections';
import {isConnectionInProgress, isConnectionUnverified} from '@libs/actions/connections';
import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {clearPolicyTagErrors, deletePolicyTags, downloadTagsCSV, openPolicyTagsPage, setPolicyTagsRequired, setWorkspaceTagEnabled} from '@libs/actions/Policy/Tag';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
Expand All @@ -44,6 +44,7 @@ import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavig
import type {WorkspaceSplitNavigatorParamList} from '@libs/Navigation/types';
import {
getCleanedTagName,
getConnectedIntegration,
getCurrentConnectionName,
getTagLists,
hasAccountingConnections as hasAccountingConnectionsPolicyUtils,
Expand Down Expand Up @@ -78,13 +79,14 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {
const policyID = route.params.policyID;
const backTo = route.params.backTo;
const policy = usePolicy(policyID);
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`);
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, {canBeMissing: true});
const {selectionMode} = useMobileSelectionMode();
const {environmentURL} = useEnvironment();
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`);
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`, {canBeMissing: true});
const isSyncInProgress = isConnectionInProgress(connectionSyncProgress, policy);
const hasSyncError = shouldShowSyncError(policy, isSyncInProgress);
const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0;
const connectedIntegration = getConnectedIntegration(policy) ?? connectionSyncProgress?.connectionName;
const isConnectionVerified = connectedIntegration && !isConnectionUnverified(policy, connectedIntegration);
const currentConnectionName = getCurrentConnectionName(policy);
const [policyTagLists, isMultiLevelTags] = useMemo(() => [getTagLists(policyTags), isMultiLevelTagsPolicyUtils(policyTags)], [policyTags]);
const canSelectMultiple = !isMultiLevelTags && (shouldUseNarrowLayout ? selectionMode?.isEnabled : true);
Expand Down Expand Up @@ -409,7 +411,7 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) {

const getHeaderText = () => (
<View style={[styles.ph5, styles.pb5, styles.pt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{!hasSyncError && isConnectedToAccounting ? (
{!hasSyncError && isConnectionVerified ? (
<Text>
<Text style={[styles.textNormal, styles.colorMuted]}>{`${translate('workspace.tags.importedFromAccountingSoftware')} `}</Text>
<TextLink
Expand Down
17 changes: 12 additions & 5 deletions src/pages/workspace/taxes/WorkspaceTaxesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSearchBackPress from '@hooks/useSearchBackPress';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import {isConnectionInProgress} from '@libs/actions/connections';
import {isConnectionInProgress, isConnectionUnverified} from '@libs/actions/connections';
import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {clearTaxRateError, deletePolicyTaxes, setPolicyTaxesEnabled} from '@libs/actions/TaxRate';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
import {getLatestErrorFieldForAnyField} from '@libs/ErrorUtils';
import goBackFromWorkspaceCentralScreen from '@libs/Navigation/helpers/goBackFromWorkspaceCentralScreen';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import {canEditTaxRate as canEditTaxRatePolicyUtils, getCurrentConnectionName, hasAccountingConnections as hasAccountingConnectionsPolicyUtils, shouldShowSyncError} from '@libs/PolicyUtils';
import {
canEditTaxRate as canEditTaxRatePolicyUtils,
getConnectedIntegration,
getCurrentConnectionName,
hasAccountingConnections as hasAccountingConnectionsPolicyUtils,
shouldShowSyncError,
} from '@libs/PolicyUtils';
import type {WorkspaceSplitNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading';
Expand Down Expand Up @@ -65,11 +71,12 @@ function WorkspaceTaxesPage({
const defaultExternalID = policy?.taxRates?.defaultExternalID;
const foreignTaxDefault = policy?.taxRates?.foreignTaxDefault;
const hasAccountingConnections = hasAccountingConnectionsPolicyUtils(policy);
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`);
const [connectionSyncProgress] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policy?.id}`, {canBeMissing: true});
const isSyncInProgress = isConnectionInProgress(connectionSyncProgress, policy);
const hasSyncError = shouldShowSyncError(policy, isSyncInProgress);

const isConnectedToAccounting = Object.keys(policy?.connections ?? {}).length > 0;
const connectedIntegration = getConnectedIntegration(policy) ?? connectionSyncProgress?.connectionName;
const isConnectionVerified = connectedIntegration && !isConnectionUnverified(policy, connectedIntegration);
const currentConnectionName = getCurrentConnectionName(policy);
const canSelectMultiple = shouldUseNarrowLayout ? selectionMode?.isEnabled : true;

Expand Down Expand Up @@ -314,7 +321,7 @@ function WorkspaceTaxesPage({

const getHeaderText = () => (
<View style={[styles.ph5, styles.pb5, styles.pt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
{!hasSyncError && isConnectedToAccounting ? (
{!hasSyncError && isConnectionVerified ? (
<Text>
<Text style={[styles.textNormal, styles.colorMuted]}>{`${translate('workspace.taxes.importedFromAccountingSoftware')} `}</Text>
<TextLink
Expand Down