Add bulk export to accounting integration#81421
Add bulk export to accounting integration#81421huult wants to merge 3 commits intoExpensify:mainfrom
Conversation
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx ts-node ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
|
@ahmedGaber93 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
…rt-accounting-integrations
| // Process each report ID | ||
| for (const reportID of reportIDs) { | ||
| const action = buildOptimisticExportIntegrationAction(connectionName, true); | ||
| const optimisticReportActionID = action.reportActionID; |
There was a problem hiding this comment.
❌ PERF-13 (docs)
The function buildOptimisticExportIntegrationAction(connectionName, true) is called inside the for loop but does not use the iterator variable reportID. This results in redundant computation - the function produces the same result for each iteration based only on connectionName and the boolean true, both of which are constant throughout the loop.
The constant label is already hoisted outside the loop correctly. Similarly, the result of buildOptimisticExportIntegrationAction should be computed once and reused:
function markAsManuallyExportedMultipleReports(reportIDs: string[], connectionName: ConnectionName) {
const label = CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName];
const baseAction = buildOptimisticExportIntegrationAction(connectionName, true);
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = [];
const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = [];
const failureData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = [];
const reportData: Array<{reportID: string; label: string; optimisticReportActionID: string}> = [];
// Process each report ID
for (const reportID of reportIDs) {
const action = {...baseAction, reportActionID: baseAction.reportActionID + reportID}; // Ensure unique IDs
const optimisticReportActionID = action.reportActionID;
// ... rest of loop
}
}Note: If buildOptimisticExportIntegrationAction generates unique IDs internally (e.g., timestamps), you may need to adjust the implementation to ensure uniqueness while still avoiding redundant computation.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| const successActions: Record<string, OptimisticExportIntegrationAction> = {}; | ||
| const optimisticReportActions: Record<string, string> = {}; | ||
|
|
||
| for (const reportID of reportIDs) { |
There was a problem hiding this comment.
❌ PERF-13 (docs)
The function buildOptimisticExportIntegrationAction(connectionName) is called inside the for loop but does not use the iterator variable reportID. This results in redundant computation - the function produces the same result for each iteration based only on connectionName, which is constant throughout the loop.
Hoist the function call outside the loop to eliminate O(n) redundant computations:
function exportMultipleReportsToIntegration(hash: number, reportIDs: string[], connectionName: ConnectionName, currentSearchKey?: SearchKey) {
if (!reportIDs.length) {
return;
}
const baseOptimisticAction = buildOptimisticExportIntegrationAction(connectionName);
const optimisticActions: Record<string, OptimisticExportIntegrationAction> = {};
const successActions: Record<string, OptimisticExportIntegrationAction> = {};
const optimisticReportActions: Record<string, string> = {};
for (const reportID of reportIDs) {
const optimisticAction = {...baseOptimisticAction, reportActionID: baseOptimisticAction.reportActionID + reportID}; // Ensure unique IDs
const successAction: OptimisticExportIntegrationAction = {...optimisticAction, pendingAction: null};
const optimisticReportActionID = optimisticAction.reportActionID;
optimisticActions[reportID] = optimisticAction;
successActions[reportID] = successAction;
optimisticReportActions[reportID] = optimisticReportActionID;
}
// ... rest of function
}Note: If buildOptimisticExportIntegrationAction generates unique IDs internally, you may need to adjust the implementation to ensure uniqueness while avoiding redundant computation.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| return reportExportOptions.includes(CONST.REPORT.EXPORT_OPTIONS.EXPORT_TO_INTEGRATION); | ||
| }; | ||
|
|
||
| // Check if all selected reports can be exported using existing logic |
There was a problem hiding this comment.
❌ PERF-2 (docs)
The expensive operation selectedReports.every(canReportBeExported) runs before checking the simple condition connectedIntegration. The canReportBeExported function calls multiple expensive operations (getReportOrDraftReport, getSecondaryExportReportActions) for each report.
Since connectedIntegration is already computed earlier in the function, we can check it BEFORE running the expensive .every() operation. If connectedIntegration is falsy, the result of canExportAllReports won't be used anyway (see the if (canExportAllReports && connectedIntegration) check below).
Move the connectedIntegration check earlier to avoid unnecessary computation:
// Check if all selected reports can be exported using existing logic
const canExportAllReports = connectedIntegration && isReportsTab && selectedReportIDs.length > 0 && includeReportLevelExport && selectedReports.every(canReportBeExported);This way, if there's no connected integration, the expensive .every() operation is skipped entirely.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f84ffac689
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| onSelected: () => { | ||
| // Show accounting integration confirmation modal | ||
| setAccountingExportModalVisible(true); | ||
| exportMultipleReportsToIntegration(hash, selectedReportIDs, connectedIntegration); |
There was a problem hiding this comment.
Pass currentSearchKey to update export search results
When users bulk-export from the Export suggested search, exportMultipleReportsToIntegration only removes exported reports from the snapshot if currentSearchKey === EXPORT (see src/libs/actions/Search.ts around the currentSearchKey check). This call doesn’t pass a search key, so in the Export search view the items will stay visible after a successful export and can be re‑exported unintentionally. Consider passing the current search key (or otherwise updating the snapshot) so the UI reflects the successful export.
Useful? React with 👍 / 👎.
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Good from product
…rt-accounting-integrations
Explanation of Change
Fixed Issues
$ #79515
PROPOSAL: #79515 (comment)
Tests
Same QA step
Offline tests
QA Steps
Precondition:
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-02-05.at.00.28.49.mov
Android: mWeb Chrome
Screen.Recording.2026-02-05.at.00.13.15.mov
iOS: Native
Screen.Recording.2026-02-05.at.00.36.15.mov
iOS: mWeb Safari
Screen.Recording.2026-02-05.at.00.16.23.mov
MacOS: Chrome / Safari
Screen.Recording.2026-02-04.at.23.45.49.mp4