Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QBO freeze branch #42543

Merged
merged 101 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
6fb62d5
Last synced just now doesnt update
tienifr Apr 30, 2024
4ab21ee
Merge branch 'main' into fix/41045
tienifr May 1, 2024
c3e0e4b
lint fix
tienifr May 1, 2024
faa4eb7
fix: lock the toggle for disabling location when the account selected…
May 4, 2024
43d57ac
fix the boolean condition
May 5, 2024
102c2bf
chore: filter out account options depending on whether the location t…
May 5, 2024
056c362
chore: lock the toggle button when the location import should be off
May 6, 2024
e74a7ae
chore: add a todo comment not to forget to change the description text
May 6, 2024
ff3397e
resolve conflicts
tienifr May 7, 2024
8ecfa6e
fix: formate date
tienifr May 7, 2024
12d407b
Merge branch 'main' into fix/41045
tienifr May 8, 2024
bcaca76
fix: typo word
tienifr May 8, 2024
fa426e3
Merge branch 'main' into fix/41045
tienifr May 10, 2024
f6e5060
convert date to string
tienifr May 10, 2024
5b420eb
fix: when there is no active tags, prevent the user from requiring ta…
May 10, 2024
790466c
fix: delete the log statement
May 10, 2024
d3be0c3
Merge branch 'main' into hayata-do-not-allow-invalid-location-account…
May 10, 2024
add3daf
fix: wrong conditional statement
May 11, 2024
c771c51
change const name and don't force in-active state
May 11, 2024
c82b2d9
Merge branch 'main' into fix/41045
tienifr May 13, 2024
69a3652
fix timeone error
tienifr May 13, 2024
68c786b
Merge branch 'main' into hayata-do-not-allow-users-from-requiring-tag…
May 13, 2024
a6a3c05
fix: duplicate declarations
May 13, 2024
e343f5b
Merge branch 'main' into fix/41045
tienifr May 14, 2024
0c8b014
remove setinterval
tienifr May 14, 2024
400144a
Add orderWeight to tag view and tag edit routes
s77rt May 14, 2024
21aef13
fix: use existing value to determine if the location is enabled or not
May 14, 2024
01d10e5
fix: don't use conditional rendering
May 14, 2024
286980f
fix: the ordering of items
May 14, 2024
a9f76f4
fix: the ordering of items
May 14, 2024
b9cf433
don't disable the switch for the location import if the location is a…
May 14, 2024
3c1b841
chore: remove todo comments
May 14, 2024
bcecada
update the UI copy
May 15, 2024
30cfcac
Merge branch 'main' into hayata-do-not-allow-invalid-location-account…
May 15, 2024
dd891b7
style: get config value from the destructuring statement
May 15, 2024
4774590
Merge branch 'main' into hayata-do-not-allow-invalid-location-account…
May 15, 2024
cf290b1
Merge branch 'main' into hayata-do-not-allow-users-from-requiring-tag…
May 16, 2024
bab0977
feat: add new parameter to API command
May 16, 2024
48457f2
feat: pass new param to the API command
May 16, 2024
1196025
feat: pass the index of the parent tag list item
May 16, 2024
b438c32
fix: use index to get the correct list of tags
May 16, 2024
f716632
Merge branch 'Expensify:main' into multi-level-tags-fix-not-found
s77rt May 17, 2024
503ca7d
lint
s77rt May 17, 2024
9b08271
fix: update the spanish translation
May 20, 2024
c684b64
Merge pull request #42149 from s77rt/multi-level-tags-fix-not-found
May 20, 2024
611b3e5
chore: make a prop required
May 21, 2024
a7064b4
chore: make API parameter required
May 21, 2024
788f237
fix: pass missing arguments
May 22, 2024
e1ec259
pass the default tag list index
May 22, 2024
8ebd1a9
fix: test
May 22, 2024
555fd58
pass default index manually
May 22, 2024
f827cdb
Merge pull request #42315 from Expensify/hayata-call-api-for-multi-le…
arosiclair May 23, 2024
db992fd
Add explicit description for each export entity
s77rt May 23, 2024
df7e67f
Merge branch 'main' into qbo-freeze-branch
May 23, 2024
e54b7a1
Added listEmptyContent prop to SelectionList
s77rt May 23, 2024
e2fea05
Avoid adding empty sections
s77rt May 23, 2024
2db6992
Merge branch 'qbo-freeze-branch' into SelectionList-listEmptyContent
s77rt May 23, 2024
6ba9dc4
fix: use `isSwitchOn` to decide if the admin should be allowed to tog…
May 23, 2024
060adaa
Add 40px bottom padding
s77rt May 23, 2024
14943e7
fix: move the hint text to the entity select page
May 23, 2024
211eeb0
lint
s77rt May 23, 2024
fa54e7c
Apply suggestions from code review
s77rt May 24, 2024
f3686bf
Update QuickbooksOutOfPocketExpenseAccountSelectPage.tsx
s77rt May 24, 2024
7367815
Update QuickbooksOutOfPocketExpenseConfigurationPage.tsx
s77rt May 24, 2024
263f798
Merge pull request #41310 from tienifr/fix/41045
mountiny May 24, 2024
b9da7f7
Merge pull request #42004 from Expensify/hayata-do-not-allow-users-fr…
May 24, 2024
a85c237
Merge pull request #42548 from s77rt/qbo-export-out-of-pocket-expense…
May 24, 2024
ac3e90b
fix: issue with the footer component
May 24, 2024
023c313
chore: remove unnecessary hint text
May 24, 2024
28d3944
Merge branch 'qbo-freeze-branch' into SelectionList-listEmptyContent
s77rt May 25, 2024
cdb176a
chore: fix the style of hint texts when there is no account to display
May 27, 2024
0688088
chore: don't display the hint text when there is misconfiguration
May 27, 2024
b503938
Rename style prop to containerStyle
s77rt May 28, 2024
f5e4c04
fix: delete unnecessary UI text
May 28, 2024
c35ab9d
Merge pull request #42561 from s77rt/SelectionList-listEmptyContent
pecanoro May 28, 2024
a0845eb
fix: add back the footer
May 29, 2024
805b67e
chore: revert the commit for changing the hint display behavior in lo…
May 29, 2024
a313d7a
chore: change the hint text behavior on the taxes page
May 29, 2024
427ca57
fix: the display text
May 29, 2024
5925a85
chore: update the text
May 29, 2024
948b665
fix: check if the company card export destination is vendor bill & cr…
May 29, 2024
911d494
chore: add the word "checks"
May 29, 2024
a421cdd
remove outdated conditions
s77rt May 30, 2024
2e061e7
Merge pull request #42019 from Krishna2323/krishna2323/issue/41326
puneetlath May 31, 2024
883b27f
lint
s77rt May 31, 2024
b687139
Readd shouldDebounceRowSelect
s77rt May 31, 2024
15452e6
Merge pull request #42883 from s77rt/s77rt-do-not-allow-invalid-locat…
May 31, 2024
7cd358e
fix: add back the check to see if the error should be shown
May 31, 2024
f769502
Merge branch 'qbo-freeze-branch' into hayata-do-not-allow-invalid-loc…
May 31, 2024
5d5d2cd
remove mistype
May 31, 2024
5ffc623
chore: replace with accountDescription
May 31, 2024
52a8ac0
remove isLocationEnabled check
May 31, 2024
a25aa19
Merge branch 'main' into qbo-freeze-branch
lakchote May 31, 2024
362167d
Fix footer styles
s77rt May 31, 2024
c97ffd3
Update src/pages/workspace/accounting/qbo/export/QuickbooksOutOfPocke…
s77rt May 31, 2024
da6232d
Merge branch 'qbo-freeze-branch' into hayata-do-not-allow-invalid-loc…
lakchote May 31, 2024
715f3da
fix prettier
lakchote May 31, 2024
f8a9176
Merge pull request #42921 from s77rt/s77rt-do-not-allow-invalid-locat…
lakchote May 31, 2024
a3729d4
chore: update outdated spanish copy
May 31, 2024
250778d
style: run prettier
May 31, 2024
d234079
Merge pull request #41638 from Expensify/hayata-do-not-allow-invalid-…
May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/BlockingViews/BlockingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ type BaseBlockingViewProps = {

/** Render custom subtitle */
CustomSubtitle?: React.ReactElement;

/** Additional styles to apply to the container */
containerStyle?: StyleProp<ViewStyle>;
};

type BlockingViewIconProps = {
Expand Down Expand Up @@ -81,6 +84,7 @@ function BlockingView({
animationStyles = [],
animationWebStyle = {},
CustomSubtitle,
containerStyle,
}: BlockingViewProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand Down Expand Up @@ -117,7 +121,7 @@ function BlockingView({
}, [styles, subtitleText, shouldEmbedLinkWithSubtitle, CustomSubtitle]);

return (
<View style={[styles.flex1, styles.alignItemsCenter, styles.justifyContentCenter, styles.ph10]}>
<View style={[styles.flex1, styles.alignItemsCenter, styles.justifyContentCenter, styles.ph10, containerStyle]}>
{animation && (
<Lottie
source={animation}
Expand Down
7 changes: 6 additions & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function BaseSelectionList<TItem extends ListItem>(
headerContent,
footerContent,
listFooterContent,
listEmptyContent,
showScrollIndicator = true,
showLoadingPlaceholder = false,
showConfirmButton = false,
Expand Down Expand Up @@ -103,6 +104,7 @@ function BaseSelectionList<TItem extends ListItem>(
const itemFocusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const [currentPage, setCurrentPage] = useState(1);
const isTextInputFocusedRef = useRef<boolean>(false);
const isEmptyList = sections.length === 0;

const incrementPage = () => setCurrentPage((prev) => prev + 1);

Expand Down Expand Up @@ -694,8 +696,11 @@ function BaseSelectionList<TItem extends ListItem>(
testID="selection-list"
onLayout={onSectionListLayout}
style={(!maxToRenderPerBatch || (shouldHideListOnInitialRender && isInitialSectionListRender)) && styles.opacity0}
ListHeaderComponent={listHeaderContent}
ListFooterComponent={listFooterContent ?? ShowMoreButtonInstance}
ListHeaderComponent={listHeaderContent && listHeaderContent}
ListEmptyComponent={listEmptyContent}
contentContainerStyle={isEmptyList && listEmptyContent ? styles.flexGrow1 : undefined}
scrollEnabled={!isEmptyList || !listEmptyContent}
onEndReached={onEndReached}
onEndReachedThreshold={onEndReachedThreshold}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
/** Custom content to display in the footer of list component. If present ShowMore button won't be displayed */
listFooterContent?: React.JSX.Element | null;

/** Content to display if the list is empty */
listEmptyContent?: React.JSX.Element | null;

/** Whether to use dynamic maxToRenderPerBatch depending on the visible number of elements */
shouldUseDynamicMaxToRenderPerBatch?: boolean;

Expand Down
5 changes: 5 additions & 0 deletions src/components/SelectionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type SelectionScreenProps = {
/** Custom content to display in the header */
headerContent?: React.ReactNode;

/** Content to display if the list is empty */
listEmptyContent?: React.JSX.Element | null;

/** Sections for the section list */
sections: Array<SectionListDataType<SelectorType>>;

Expand Down Expand Up @@ -63,6 +66,7 @@ function SelectionScreen({
displayName,
title,
headerContent,
listEmptyContent,
sections,
listItem,
initiallyFocusedOptionKey,
Expand Down Expand Up @@ -102,6 +106,7 @@ function SelectionScreen({
showScrollIndicator
shouldShowTooltips={false}
initiallyFocusedOptionKey={initiallyFocusedOptionKey}
listEmptyContent={listEmptyContent}
/>
</ScreenWrapper>
</AccessOrNotFoundWrapper>
Expand Down
20 changes: 14 additions & 6 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1938,10 +1938,11 @@ export default {
customersDescription: 'Choose whether to import customers/projects and see where customers/projects are displayed.',
locationsDescription: 'Choose whether to import locations, and see where locations are displayed.',
taxesDescription: 'Choose whether to import tax rates and tax defaults from your accounting integration.',
locationsAdditionalDescription: `QuickBooks Online does not support adding a location to vendor bills or checks. Update your export preference to journal entry if you'd like to import locations as tags.`,
outOfPocketLocationEnabledDescription:
'Note: QuickBooks Online does not support a field for locations on vendor bill or check exports. As you have locations enabled on your workspace, this export option is unavailable.',
taxesJournalEntrySwitchNote:
'Note: QuickBooks Online does not support a field for tax on Journal Entry exports. Change your export preference to Vendor Bill or Check to import taxes.',
locationsAdditionalDescription:
'Locations are imported as Tags. This limits exporting expense reports as Vendor Bills or Checks to QuickBooks Online. To unlock these export options, either disable Locations import or upgrade to the Control Plan to export Locations encoded as a Report Field.',
export: 'Export',
exportAs: 'Export as',
exportDescription: 'Configure how data in Expensify gets exported to QuickBooks Online.',
Expand Down Expand Up @@ -1981,20 +1982,23 @@ export default {
exportPreferredExporterNote: 'This can be any workspace admin, but must be a Domain Admin if you set different export accounts for individual company cards in Domain Settings.',
exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.',
exportOutOfPocketExpensesDescription: 'Set how out-of-pocket expenses export to QuickBooks Online.',
exportCheckDescription: "We'll create a single itemized check for each Expensify report. You can write the check from your bank account of choice (below).",
exportJournalEntryDescription: "We'll create a single itemized journal entry for each Expensify report. You can post the offset entry to your account of choice (below).",
exportVendorBillDescription:
"We'll create a single itemized vendor bill for each Expensify report. If the period of the bill is closed, we'll post to the 1st of the next open period. You can add the vendor bill to your A/P account of choice (below).",
accountsPayable: 'Accounts payable',
account: 'Account',
accountDescription: 'This is your chosen account to post the journal entry offset for each report.',
accountsPayable: 'Accounts payable',
accountsPayableDescription: 'This is your chosen A/P account, against which vendor bills for each report are created.',
bankAccount: 'Bank account',
bankAccountDescription: 'This is your chosen bank account to write checks from.',
optionBelow: 'Choose an option below:',
companyCardsLocationEnabledDescription:
'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations from, this this export option is unavailable.',
'Note: QuickBooks Online does not support a field for locations on vendor bill exports. As you have locations enabled on your workspace, this export option is unavailable.',
outOfPocketTaxEnabledDescription:
"Note: QuickBooks Online doesn't support a field for tax on Journal Entry exports. Because you have tax tracking enabled on your workspace, this export option is unavailable.",
outOfPocketTaxEnabledError: 'Journal entry is not available when taxes enabled. please select a different export option.',
outOfPocketLocationEnabledError: 'Vendor Bills are not available when locations are enabled. Please select a different export option.',
outOfPocketLocationEnabledDescription:
'Note: QuickBooks Online does not support a field for Locations as Tags on Vendor Bills exports. As you import Locations as Tags, this export option is unavailable.',
advancedConfig: {
advanced: 'Advanced',
autoSync: 'Auto-sync',
Expand Down Expand Up @@ -2035,6 +2039,8 @@ export default {
[`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.CHECK}Error`]: 'Check is not available when locations are enabled. Please select a different export option.',
[`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY}Error`]: 'Journal entry is not available when taxes enabled. please select a different export option.',
},
noAccountsFound: 'No accounts found',
noAccountsFoundDescription: 'Add the account in Quickbooks Online and sync the connection again',
},
xero: {
organization: 'Xero organization',
Expand Down Expand Up @@ -2113,6 +2119,8 @@ export default {
},
exportPreferredExporterNote: 'This can be any workspace admin, but must be a domain admin if you set different export accounts for individual company cards in domain settings.',
exportPreferredExporterSubNote: 'Once set, the preferred exporter will see reports for export in their account.',
noAccountsFound: 'No accounts found',
noAccountsFoundDescription: 'Add the account in Xero and sync the connection again',
},
type: {
free: 'Free',
Expand Down
14 changes: 12 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,7 +1965,7 @@ export default {
taxesJournalEntrySwitchNote:
'Nota: QuickBooks Online no admite un campo para impuestos al exportar entradas en el libro diario. Cambia tu preferencia de exportación a Factura de Proveedor o Cheque para importar impuestos.',
locationsAdditionalDescription:
'Los lugares son importados como Etiquegas. Esto limita a exportar los informes de gastos como Factura del Proveedor o Cheques a Quicbooks Online. Para desbloquear estas opciones de exportación desactiva la importación de Lugares o cambia al Plan Control para exportar Lugares como Campos de Informes.',
'QuickBooks Online no permite añadir una ubicación a las facturas de proveedores o a los cheques. Actualice su preferencia de exportación a asiento contable si desea importar ubicaciones como etiquetas.',
export: 'Exportar',
exportAs: 'Exportar cómo',
exportExpenses: 'Exportar gastos de bolsillo como',
Expand Down Expand Up @@ -2000,26 +2000,32 @@ export default {
exportInvoicesDescription: 'Las facturas se exportarán a esta cuenta en QuickBooks Online.',
exportCompanyCardsDescription: 'Establece cómo se exportan las compras con tarjeta de empresa a QuickBooks Online.',
account: 'Cuenta',
accountDescription: 'Esta es la cuenta elegida para contabilizar la compensación de la entrada de diario de cada informe.',
vendor: 'Proveedor',
defaultVendor: 'Proveedor predeterminado',
defaultVendorDescription: 'Establece un proveedor predeterminado que se aplicará a todas las transacciones con tarjeta de crédito al momento de exportarlas.',
accountsPayable: 'Cuentas por pagar',
accountsPayableDescription: 'Esta es la cuenta de cuentas por pagar elegida, contra la cual se crean las facturas de proveedores para cada informe.',
bankAccount: 'Cuenta bancaria',
bankAccountDescription: 'Esta es la cuenta bancaria elegida para emitir cheques.',
optionBelow: 'Elija una opción a continuación:',
companyCardsLocationEnabledDescription:
'Nota: QuickBooks Online no admite un campo para Ubicaciones como etiquetas en las exportaciones de facturas de proveedores. A medida que importa ubicaciones, esta opción de exportación no está disponible.',
exportPreferredExporterNote:
'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.',
exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en tu cuenta.',
exportOutOfPocketExpensesDescription: 'Establezca cómo se exportan los gastos de bolsillo a QuickBooks Online.',
exportCheckDescription: 'Crearemos un único cheque desglosado para cada informe de Expensify. Puedes emitir el cheque desde la cuenta bancaria que elijas (más abajo).',
exportJournalEntryDescription:
'Crearemos una única entrada de diario desglosada para cada informe de Expensify. Puedes enviar la compensación de la entrada de diario a la cuenta que elijas (más abajo).',
exportVendorBillDescription:
'Crearemos una única factura de proveedor detallada para cada informe de Expensify. Si el período de la factura está cerrado, lo publicaremos en el día 1 del siguiente período abierto. Puede agregar la factura del proveedor a la cuenta A/P de tu elección (a continuación).',
outOfPocketTaxEnabledDescription:
'Nota: QuickBooks Online no admite un campo para impuestos en las exportaciones de Anotación en el diario. Debido a que tienes habilitado el seguimiento de impuestos en tu área de trabajo, esta opción de exportación no está disponible.',
outOfPocketTaxEnabledError: 'La Anotacion en el diario no está disponible cuando los impuestos están activados. Por favor, selecciona una opción de exportación diferente.',
outOfPocketLocationEnabledError: 'Las facturas de proveedores no están disponibles cuando las ubicaciones están activadas. Seleccione otra opción de exportación.',
outOfPocketLocationEnabledDescription:
'Nota: QuickBooks Online no admite un campo para Ubicaciones como Etiquetas en las exportaciones de Facturas de Proveedor. Al importar Ubicaciones como Etiquetas, esta opción de exportación no está disponible.',
'Nota: QuickBooks Online no permite añadir una ubicación a las facturas de proveedores o a los cheques. Al importar ubicaciones como etiquetas, esta opción de exportación no está disponible.',

advancedConfig: {
advanced: 'Avanzado',
Expand Down Expand Up @@ -2067,6 +2073,8 @@ export default {
[`${CONST.QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE.JOURNAL_ENTRY}Error`]:
'El asiento de diario no está disponible cuando los impuestos están habilitados. seleccione una opción de exportación diferente.',
},
noAccountsFound: 'No se ha encontrado ninguna cuenta',
noAccountsFoundDescription: 'Añade la cuenta en Quickbooks Online y sincroniza de nuevo la conexión',
},
xero: {
organization: 'Organización Xero',
Expand Down Expand Up @@ -2149,6 +2157,8 @@ export default {
exportPreferredExporterNote:
'Puede ser cualquier administrador del espacio de trabajo, pero debe ser un administrador de dominio si configura diferentes cuentas de exportación para tarjetas de empresa individuales en la configuración del dominio.',
exportPreferredExporterSubNote: 'Una vez configurado, el exportador preferido verá los informes para exportar en su cuenta.',
noAccountsFound: 'No se ha encontrado ninguna cuenta',
noAccountsFoundDescription: 'Añade la cuenta en Xero y sincroniza de nuevo la conexión',
},
type: {
free: 'Gratis',
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/WorkspaceNewRoomPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ function WorkspaceNewRoomPage({policies, reports, formState, session, activePoli
<>
<BlockingView
icon={Illustrations.TeleScope}
iconWidth={variables.emptyWorkspaceIconWidth}
iconHeight={variables.emptyWorkspaceIconHeight}
iconWidth={variables.emptyListIconWidth}
iconHeight={variables.emptyListIconHeight}
title={translate('workspace.emptyWorkspace.notFound')}
subtitle={translate('workspace.emptyWorkspace.description')}
shouldShowLink={false}
Expand Down
15 changes: 11 additions & 4 deletions src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useMemo, useRef, useState} from 'react';
import {formatDistanceToNow} from 'date-fns';
import React, {useEffect, useMemo, useRef, useState} from 'react';
import {ActivityIndicator, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
Expand Down Expand Up @@ -113,13 +114,16 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting
const {isSmallScreenWidth, windowWidth} = useWindowDimensions();
const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState<AnchorPosition>({horizontal: 0, vertical: 0});
const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false);
const [datetimeToRelative, setDateTimeToRelative] = useState('');
const threeDotsMenuContainerRef = useRef<View>(null);

const isSyncInProgress = !!connectionSyncProgress?.stageInProgress && connectionSyncProgress.stageInProgress !== CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.JOB_DONE;

const accountingIntegrations = Object.values(CONST.POLICY.CONNECTIONS.NAME).filter((name) => !(name === CONST.POLICY.CONNECTIONS.NAME.XERO && !canUseXeroIntegration));
const connectedIntegration = accountingIntegrations.find((integration) => !!policy?.connections?.[integration]) ?? connectionSyncProgress?.connectionName;
const policyID = policy?.id ?? '';
const successfulDate = policy?.connections?.quickbooksOnline?.lastSync?.successfulDate;
const formattedDate = useMemo(() => (successfulDate ? new Date(successfulDate) : new Date()), [successfulDate]);

const policyConnectedToXero = connectedIntegration === CONST.POLICY.CONNECTIONS.NAME.XERO;

Expand All @@ -144,6 +148,10 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting
[translate, policyID, isOffline, connectedIntegration],
);

useEffect(() => {
setDateTimeToRelative(formatDistanceToNow(formattedDate, {addSuffix: true}));
}, [formattedDate]);

const connectionsMenuItems: MenuItemData[] = useMemo(() => {
if (isEmptyObject(policy?.connections) && !isSyncInProgress) {
return accountingIntegrations.map((integration) => {
Expand Down Expand Up @@ -176,9 +184,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting
errorText: shouldShowSynchronizationError ? translate('workspace.accounting.syncError', connectedIntegration) : undefined,
errorTextStyle: [styles.mt5],
shouldShowRedDotIndicator: true,
description: isSyncInProgress
? translate('workspace.accounting.connections.syncStageName', connectionSyncProgress.stageInProgress)
: translate('workspace.accounting.lastSync'),
description: isSyncInProgress ? translate('workspace.accounting.connections.syncStageName', connectionSyncProgress.stageInProgress) : datetimeToRelative,
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB. Remove workspace.accounting.lastSync as it's no longer used

rightComponent: isSyncInProgress ? (
<ActivityIndicator
style={[styles.popoverMenuIcon]}
Expand Down Expand Up @@ -270,6 +276,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting
policyConnectedToXero,
currentXeroOrganizationName,
tenants.length,
datetimeToRelative,
accountingIntegrations,
currentXeroOrganization?.id,
]);
Expand Down
Loading
Loading