diff --git a/src/languages/en.ts b/src/languages/en.ts index ecd4613af086..7bff9ca329e2 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -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', diff --git a/src/languages/es.ts b/src/languages/es.ts index 99f3de0bb14d..505f1727e85d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -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', diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 4a2a066c3004..ab0ace26bc9d 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -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; + 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(); @@ -81,7 +82,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { const [datetimeToRelative, setDateTimeToRelative] = useState(''); const threeDotsMenuContainerRef = useRef(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; @@ -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, @@ -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 ? ( 0; + const connectedIntegration = getConnectedIntegration(policy) ?? connectionSyncProgress?.connectionName; + const isConnectionVerified = connectedIntegration && !isConnectionUnverified(policy, connectedIntegration); const currentConnectionName = getCurrentConnectionName(policy); const isQuickSettingsFlow = !!backTo; const {canUseLeftHandBar} = usePermissions(); @@ -337,7 +338,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { const getHeaderText = () => ( - {!hasSyncError && isConnectedToAccounting ? ( + {!hasSyncError && isConnectionVerified ? ( {`${translate('workspace.categories.importedFromAccountingSoftware')} `} ([]); 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); @@ -214,7 +215,7 @@ function WorkspaceReportFieldsPage({ const getHeaderText = () => ( - {!hasSyncError && isConnectedToAccounting ? ( + {!hasSyncError && isConnectionVerified ? ( {`${translate('workspace.reportFields.importedFromAccountingSoftware')} `} 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); @@ -409,7 +411,7 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { const getHeaderText = () => ( - {!hasSyncError && isConnectedToAccounting ? ( + {!hasSyncError && isConnectionVerified ? ( {`${translate('workspace.tags.importedFromAccountingSoftware')} `} 0; + const connectedIntegration = getConnectedIntegration(policy) ?? connectionSyncProgress?.connectionName; + const isConnectionVerified = connectedIntegration && !isConnectionUnverified(policy, connectedIntegration); const currentConnectionName = getCurrentConnectionName(policy); const canSelectMultiple = shouldUseNarrowLayout ? selectionMode?.isEnabled : true; @@ -314,7 +321,7 @@ function WorkspaceTaxesPage({ const getHeaderText = () => ( - {!hasSyncError && isConnectedToAccounting ? ( + {!hasSyncError && isConnectionVerified ? ( {`${translate('workspace.taxes.importedFromAccountingSoftware')} `}