Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/hooks/useExportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function useExportActions({reportID, policy, onPDFModalOpen}: UseExportActionsPa
jsonQuery: '{}',
reportIDList: [moneyRequestReport.reportID],
transactionIDList,
policyID: policyID ?? moneyRequestReport.policyID,
policyID,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Pass report policyID for account-level template exports

For account-level in-app templates, getExportTemplates creates entries without template.policyID, so this call now sends policyID: undefined whenever a user exports a workspace report with one of those templates. The backend no longer has the workspace context needed to resolve policy fields/GL codes, so account-level custom template exports from the report menu produce incorrect or missing workspace-specific columns; the selection-toolbar path still passes policy?.id for the same API call.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It;s a straight revert

});
};

Expand Down
13 changes: 2 additions & 11 deletions src/hooks/useSearchBulkActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,22 +551,14 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
}
const serializedQuery = queryJSON ? serializeQueryJSONForBackend(queryJSON) : JSON.stringify(queryJSON);

// Only fall back to the selection's policyID when every selected transaction belongs to the same real workspace.
// selectedPolicyIDs filters out falsy policyIDs, so a mix of one workspace expense and policy-less (personal/unreported)
// expenses would otherwise collapse to a single ID and incorrectly resolve GL codes against that workspace.
const allSelectedHavePolicy = Object.values(selectedTransactions).every((transaction) => !!transaction.policyID);
const selectedPolicyID = allSelectedHavePolicy && selectedPolicyIDs.length === 1 ? selectedPolicyIDs.at(0) : undefined;
const queryPolicyID = queryJSON?.policyID?.length === 1 ? queryJSON.policyID.at(0) : undefined;
const exportPolicyID = policyID ?? (areAllMatchingItemsSelected ? queryPolicyID : selectedPolicyID);

if (areAllMatchingItemsSelected) {
queueExportSearchWithTemplate({
templateName,
templateType,
jsonQuery: serializedQuery,
reportIDList: [],
transactionIDList: [],
policyID: exportPolicyID,
policyID,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore workspace fallback for search template exports

When users choose an account-level custom template from search, template.policyID is undefined. For a single-workspace selection or an “all matching” search filtered to one policy, this branch now queues policyID: undefined instead of deriving the workspace from the selection/query, so workspace-specific fields in the exported template resolve incorrectly even though all exported items belong to one workspace.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a straight revert

});
} else {
const isGroupExport = !!queryJSON?.groupBy && selectedTransactionsKeys.some((key) => key.startsWith(CONST.SEARCH.GROUP_PREFIX));
Expand All @@ -576,7 +568,7 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
jsonQuery: isGroupExport ? serializeQueryJSONForBackend(addSelectedGroupsFilter(queryJSON, selectedTransactions, currentSearchResults?.data)) : '{}',
reportIDList: isGroupExport ? [] : selectedTransactionReportIDs,
transactionIDList: isGroupExport ? [] : selectedTransactionsKeys,
policyID: exportPolicyID,
policyID,
});
}

Expand All @@ -603,7 +595,6 @@ function useSearchBulkActions({queryJSON}: UseSearchBulkActionsParams) {
queryJSON,
selectedTransactionReportIDs,
selectedTransactionsKeys,
selectedPolicyIDs,
],
);

Expand Down
Loading