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

Make sure we do not show integration configurations menus if there is no lastSync object #47871

Merged
merged 5 commits into from
Aug 23, 2024
Merged
Changes from all commits
Commits
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
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)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this for all the connections?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All non-netsuite connections yes. Those use the lastSync object.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it.

return true;
}

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

Expand Down
Loading