Skip to content

Fix export condition #61260

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

Merged
merged 13 commits into from
May 7, 2025
5 changes: 5 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ function isExportIntegrationAction(reportAction: OnyxInputOrEntry<ReportAction>)
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.EXPORTED_TO_INTEGRATION;
}

function isIntegrationMessageAction(reportAction: OnyxInputOrEntry<ReportAction>): boolean {
return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.INTEGRATIONS_MESSAGE;
}

/**
* We are in the process of deprecating reportAction.originalMessage and will be setting the db version of "message" to reportAction.message in the future see: https://github.com/Expensify/App/issues/39797
* In the interim, we must check to see if we have an object or array for the reportAction.message, if we have an array we will use the originalMessage as this means we have not yet migrated.
Expand Down Expand Up @@ -2438,6 +2442,7 @@ export {
isLinkedTransactionHeld,
isMemberChangeAction,
isExportIntegrationAction,
isIntegrationMessageAction,
isMessageDeleted,
useNewTableReportViewActionRenderConditionals,
isModifiedExpenseAction,
Expand Down
11 changes: 10 additions & 1 deletion src/libs/ReportPrimaryActionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import {
canAddTransaction as canAddTransactionUtil,
getMoneyRequestSpendBreakdown,
getParentReport,
hasExportError as hasExportErrorUtil,
isArchivedReport,
isClosedReport as isClosedReportUtils,
isCurrentUserSubmitter,
isExpenseReport as isExpenseReportUtils,
isExported as isExportedUtil,
isHoldCreator,
isInvoiceReport as isInvoiceReportUtils,
isIOUReport as isIOUReportUtils,
Expand Down Expand Up @@ -171,7 +173,14 @@ function isExportAction(report: Report, policy?: Policy) {

const connectedIntegration = getConnectedIntegration(policy);
const syncEnabled = hasIntegrationAutoSync(policy, connectedIntegration);
if (syncEnabled) {
const reportActions = getAllReportActions(report.reportID);
const isExported = isExportedUtil(reportActions);
if (isExported) {
return false;
}

const hasExportError = hasExportErrorUtil(reportActions);
if (syncEnabled && !hasExportError) {
return false;
}

Expand Down
14 changes: 14 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ import {
isDeletedParentAction,
isExportIntegrationAction,
isForwardedAction,
isIntegrationMessageAction,
isMarkAsClosedAction,
isModifiedExpenseAction,
isMoneyRequestAction,
Expand Down Expand Up @@ -10329,6 +10330,18 @@ function isExported(reportActions: OnyxEntry<ReportActions> | ReportAction[]) {
return Object.values(reportActions).some((action) => isExportIntegrationAction(action));
}

function hasExportError(reportActions: OnyxEntry<ReportActions> | ReportAction[]) {
if (!reportActions) {
return false;
}

if (Array.isArray(reportActions)) {
return reportActions.some((action) => isIntegrationMessageAction(action));
}

return Object.values(reportActions).some((action) => isIntegrationMessageAction(action));
}

function getApprovalChain(policy: OnyxEntry<Policy>, expenseReport: OnyxEntry<Report>): string[] {
const approvalChain: string[] = [];
const fullApprovalChain: string[] = [];
Expand Down Expand Up @@ -10817,6 +10830,7 @@ export {
getIntegrationIcon,
canBeExported,
isExported,
hasExportError,
getHelpPaneReportType,
hasOnlyNonReimbursableTransactions,
getReportLastMessage,
Expand Down
Loading