Skip to content

Commit

Permalink
Merge pull request #47871 from Expensify/yuwen-lastSync
Browse files Browse the repository at this point in the history
Make sure we do not show integration configurations menus if there is no lastSync object
  • Loading branch information
yuwenmemon authored Aug 23, 2024
2 parents b451efd + a54733b commit 96ddacf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libs/actions/connections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxCommon from '@src/types/onyx/OnyxCommon';
import type {ConnectionName, Connections, PolicyConnectionName} from '@src/types/onyx/Policy';
import type Policy from '@src/types/onyx/Policy';
import {isEmptyObject} from '@src/types/utils/EmptyObject';

type ConnectionNameExceptNetSuite = Exclude<ConnectionName, typeof CONST.POLICY.CONNECTIONS.NAME.NETSUITE>;

Expand Down Expand Up @@ -382,7 +383,7 @@ function getSynchronizationErrorMessage(policy: OnyxEntry<Policy>, connectionNam
}

const connection = policy?.connections?.[connectionName];
if (isSyncInProgress || connection?.lastSync?.isSuccessful) {
if (isSyncInProgress || isEmptyObject(connection?.lastSync) || connection?.lastSync?.isSuccessful) {
return;
}
return `${syncError} ("${connection?.lastSync?.errorMessage}")`;
Expand All @@ -403,6 +404,12 @@ function isConnectionUnverified(policy: OnyxEntry<Policy>, connectionName: Polic
if (connectionName === CONST.POLICY.CONNECTIONS.NAME.NETSUITE) {
return !(policy?.connections?.[CONST.POLICY.CONNECTIONS.NAME.NETSUITE]?.verified ?? true);
}

// If the connection has no lastSync property, we'll consider it unverified
if (isEmptyObject(policy?.connections?.[connectionName]?.lastSync)) {
return true;
}

return !(policy?.connections?.[connectionName]?.lastSync?.isConnected ?? true);
}

Expand Down

0 comments on commit 96ddacf

Please sign in to comment.