You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-06-26] [Due for payment 2026-06-25] [$250] Both Export to accounting options don't show in the bulk select menu until opening the report first. #92976
Version Number: v9.4.0-2 Reproducible in staging?: Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by:@Kel-Expensify Slack conversation (hyperlinked to channel name): #expensify-bugs
Action Performed:
Connect to an accounting solution
Create a bunch of reports > get them into the approved state
Clear cache and restart
Go to Spend > Reports > Select an approved report
Observe neither Export to accounting options in the bulk select menu (i.e "Export to NetSuite" & "Mark as manually exported")
Open the report
Go back to Spend > Reports > Select an approved report
Observe both buttons now appear in the bulk select menu.
Expected Result:
The report shouldn't need to be opened first for the buttons to show.
Actual Result:
You have to open the report first.
Workaround:
Open the report first, but that defeats the purpose of the feature.
Platforms:
Select the officially supported platforms where the issue was reproduced:
The two export-to-accounting options in the Search bulk-select menu are computed in useSearchBulkActions, and their visibility reads from the live Onyx collections (policy_* and report_*) instead of the Search snapshot (currentSearchResults.data).
Two gates fail on a fresh load:
The integration gate — useSearchBulkActions.ts:1149-1154 reads policy from policies (the live useOnyx(POLICY) collection at line 324) and calls getConnectedIntegration(policy), which needs policy.connections. The whole menu block at line 1194 is wrapped in if (connectedIntegration).
The per-report gate — canReportBeExported at line 1166 reads completeReport from allReports (live useOnyx(REPORT)) and returns false immediately if it's missing.
On a fresh load after clearing cache, the Search > Reports list hydrates the snapshot (currentSearchResults.data["report_<id>"] / ["policy_<id>"]) but does not write those reports/policies into the live report_* / policy_* collections. So both gates evaluate against empty data and the options are hidden.
Opening the report fires openReport() (SearchMoneyRequestReportPage.tsx:208); the OpenReport response populates the live report_<id>andpolicy_<id>.connections. On return to Search both gates now pass — which is exactly the "open it first" workaround in the report.
The tell that this is the bug: the sibling transaction logic in the same hook already reads from the snapshot first and only falls back to live Onyx — useSearchBulkActions.ts:273 — but the export logic was never given that fallback.
Evidence & data flow
getSecondaryExportReportActions → isExportAction / isMarkAsExportedAction (ReportSecondaryActionUtils.ts:469-558) both short-circuit on getValidConnectedIntegration(policy), which inspects policy.connections.
getConnectedIntegration / getValidConnectedIntegration read policy?.connections?.[integration] (PolicyUtils.ts:1986-2031). connections is an optional field on Policy and is only hydrated by an API response.
The snapshot already carries policy_* / report_* entries and is read elsewhere in this hook (e.g. useSearchBulkActions.ts:432-438) — but getExportOptions/canReportBeExported ignore it and read live Onyx only.
Flow: load Search → snapshot filled, live report_*/policy_* empty → select approved report → both gates fail → options hidden. Open report → OpenReport populates live report_<id> + policy_<id>.connections → back to Search → gates pass → options appear.
What changes do you think we should make in order to solve the problem?
Make the export-visibility logic read from the Search snapshot first, falling back to live Onyx — mirroring the pattern already used at useSearchBulkActions.ts:273:
In canReportBeExported (lines 1165-1166), resolve completeReport and reportPolicy from currentSearchResults.data first, then allReports / policies.
In the integration gate (line 1149), resolve policy from the snapshot first as well so getConnectedIntegration(policy) sees connections.
⚠️One thing to verify before implementing: this client-only fix works only if the Search API snapshot includes policy.connections (and the config.autoSync it reads). If the backend Search response strips connections from the policy snapshot, the fix must instead live in the backend (extend the Search response to include policy.connections) — which is outside the App repo and would need an internal engineer. Worth confirming the snapshot shape for an approved report on a connected policy first.
What alternative solutions did you explore? (Optional)
Backend: extend the Search API response to write the full policy (with connections) into the live policy_* collection, so the existing live-Onyx checks pass. Outside the App repo.
Side-fetch: when a report is selected in Search bulk mode, proactively fetch the policy connections for its policyID. More requests; not preferred over the snapshot fallback.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/92976) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
Please re-state the problem that we are trying to solve in this issue.
On Spend > Reports, after connecting an accounting integration and selecting approved reports in the bulk-select menu, the report-level accounting export options such as "Export to NetSuite" and "Mark as manually exported" are missing until the user opens one of those reports first.
What is the root cause of that problem?
The bulk action menu is calculating report-level export eligibility from the full report entry in the ONYXKEYS.COLLECTION.REPORT collection, but the Spend > Reports search/list view can have the selected report available only as search result data after a cache clear.
In SearchContext, when a report-group row is selected, selectedReports is built from the search list item. That list item is already a TransactionReportGroupListItemType, which extends Report, but the selection state strips it down to a smaller object.
Then useSearchBulkActions decides whether to show the two integration export options with canReportBeExported(). That helper does this:
So on a cold cache, the report row can be visible and selected from the search snapshot, but if allReports[reportID] has not been hydrated yet, both canExportAllReportsToIntegration and canMarkAllReportsAsExported become false. Opening the report hydrates the full report Onyx entry, so the exact same bulk-selection path starts passing and the two options appear.
What changes do you think we should make in order to solve the problem?
Make the report-level bulk export eligibility use the report data that is already available from the search/list result before falling back to the full Onyx report collection.
Concretely:
Preserve the selected report row's report data when building selectedReports in SearchContext, or otherwise keep enough of the Report fields on the selected report object for secondary action checks.
In useSearchBulkActions's canReportBeExported(), resolve the report in this order:
allReports[REPORT + reportID], when it exists;
the report entry in currentSearchResults.data[REPORT + reportID], when present;
the selected report/list item data preserved from SearchContext.
Pass that resolved report into getSecondaryExportReportActions() instead of returning false just because the standalone report collection entry is missing.
Keep the existing policy/accounting checks unchanged. The fix should only remove the artificial dependency on opening the report first; it should not make export actions appear for reports that getSecondaryExportReportActions() would reject.
Add regression coverage around the Spend > Reports bulk menu with an approved report whose search result exists but whose ONYXKEYS.COLLECTION.REPORT + reportID entry is not loaded. The test should verify that the integration export item and "Mark as manually exported" item are still included when getSecondaryExportReportActions() would allow them, and that the normal non-eligible report cases remain hidden.
What alternative solutions did you explore? (Optional)
Forcing the app to fetch or hydrate every selected report before opening the bulk menu would also make allReports[reportID] exist, but it adds extra loading and keeps the UI coupled to a cache side effect. Using the already-loaded search result report is more direct and matches how the Reports list can render and select the report before the detail page has ever been opened.
Please re-state the problem that we are trying to solve in this issue.
In Spend > Reports, when an approved report is selected, the bulk‑select menu does not show the two accounting export options ("Export to NetSuite" and "Mark as manually exported") on a fresh load (after clearing cache and restarting). The options only appear after the user opens the report once and navigates back. They should be available immediately, without the user having to open the report first.
What is the root cause of that problem?
The bulk‑select export options are gated on whether the report exists in the full report_ Onyx collection (allReports), which is only populated for a report once that report has been opened (an OpenReport call writes the full report into report_<reportID>). On a fresh load the report only lives in the Search snapshot, so the gate fails and both options are hidden.
canReportBeExported reads the report from allReports and returns false when it is missing, instead of falling back to the Search snapshot the menu already has. This early return is the bug:
Both export options are computed by calling canReportBeExported for every selected report, so when it returns false for an unopened report, neither "Export to integration" nor "Mark as manually exported" is added to the menu:
The eligibility check itself (getSecondaryExportReportActions) only needs report fields that are already present in the Search snapshot — type, statusNum/stateNum, policyID, ownerAccountID, etc. It does not require any data that is exclusive to the opened‑report payload, so requiring the full report_ entry is unnecessary:
// Add any custom IS templates that have been added to the user's account as export options
for(consttemplateofexportTemplates){
options.push(template.name);
}
returnoptions;
}
The same hook already establishes the correct pattern elsewhere — it reads the report from the Search snapshot first and falls back to allReports — which is exactly the resilience missing in canReportBeExported:
What changes do you think we should make in order to solve the problem?
All suggested code is TypeScript and only shows the lines that actually change.
Make canReportBeExported fall back to the Search snapshot (currentSearchResults?.data) when the full report is not yet in allReports, mirroring the existing pattern at line 273. The original block is shown by the permalink in the root cause above; the changed lines become:
currentSearchResults is already destructured in this hook (const {currentSearchResults} = useSearchResultsContext();) and is used throughout getExportOptions, so it is in scope and no new dependency is introduced. With the snapshot fallback, getSecondaryExportReportActions receives the report data on first render and both options appear without the report needing to be opened.
A verification step should confirm: (1) on a fresh load both options appear for an approved report; (2) the options remain correct after the report is opened (where allReports now takes precedence, preserving the freshest data); and (3) non‑exportable reports (e.g. open/processing, no connection) still correctly hide the options.
What alternative solutions did you explore? (Optional)
Use the report argument (the selected snapshot report) directly instead of re‑deriving completeReport.canReportBeExported already receives the selected report object, so it could pass report straight into getSecondaryExportReportActions. Rejected as the primary fix because keeping the allReports lookup as the preferred source ensures the freshest data once a report has been opened/updated; the snapshot is used only as a fallback. (Functionally close to the proposed fix, but the snapshot‑fallback form is more consistent with line 273.)
Prefetch the full reports via OpenReport when the Reports search results load. This would populate allReports so the existing gate passes. Rejected because it fires N network requests just to render a menu, defeats the purpose of the Search snapshot, and adds latency and load for what is purely a client‑side eligibility check.
Relax the gate by removing the if (!completeReport) return false; guard and computing options from whatever data is available. Rejected because it risks getSecondaryExportReportActions receiving an undefined report and could surface options for ineligible reports; the snapshot fallback keeps a valid Report object flowing into the check.
Please re-state the problem that we are trying to solve in this issue.
On Web (Spend > Reports), after a fresh cache + restart, selecting an approved report does not show the "Export to NetSuite" or "Mark as manually exported" options in the bulk select menu. The options only appear after the user opens the report once and goes back. Expected: both options should be available without having to open the report first.
What is the root cause of that problem?
getExportOptions in useSearchBulkActions.ts derives the workspace policy from the Onyx collection at two distinct points, and both fail on a cold load:
Point 1 — connectedIntegration gate (line ~1149–1154).policy is resolved as:
The entire export submenu is wrapped in if (connectedIntegration). On a fresh load ONYXKEYS.COLLECTION.POLICY has not yet hydrated, so policy is undefined, connectedIntegration is undefined, and the if branch is never entered — neither option is rendered at all.
Point 2 — canReportBeExported predicate (lines ~1160–1181). Inside the predicate, completeReport and reportPolicy are resolved exclusively from the Onyx collections:
On a fresh load the report exists in the search snapshot (currentSearchResults.data) — which is why it renders in the list — but its full record has not yet been hydrated into ONYXKEYS.COLLECTION.REPORT. With completeReport undefined, the predicate returns false early, so canExportAllReportsToIntegration and canMarkAllReportsAsExported are both false even if the connectedIntegration gate were somehow passed. Opening the report hydrates both Onyx collections, after which both guards pass — matching the reproduction exactly.
What changes do you think we should make in order to solve the problem?
Three targeted edits to src/hooks/useSearchBulkActions.ts, all within getExportOptions:
1. Add a snapshot fallback when deriving policy (fixes the connectedIntegration gate, line ~1149).
This ensures getConnectedIntegration(policy) returns the integration name even before ONYXKEYS.COLLECTION.POLICY has hydrated, so the if (connectedIntegration) branch is entered and the options are rendered.
2. Add snapshot fallbacks inside canReportBeExported for both completeReport and reportPolicy (fixes the predicate, lines ~1165–1166).
This mirrors the pattern already used elsewhere in this same file — for example, shouldShowBulkDuplicateOption's getReportOrDraftReport(reportID, searchReports) usage and the duplicate-option block at line 273 — where the search snapshot is consulted as a fallback for the Onyx collection. With a real completeReport, getSecondaryExportReportActions can determine eligibility, and with a real reportPolicy it receives the connection info needed to do so.
3. No dependency array change needed.currentSearchResults?.data is already present in the headerButtonsOptionsuseMemo dependency array, so no additional wiring is required.
4. No platform twin needed — the hook is shared and the issue is reported on Web/MacOS Chrome only; the same code path runs on all platforms.
What alternative solutions did you explore? (Optional)
Eagerly hydrating selected reports into ONYXKEYS.COLLECTION.REPORT on selection would fix it globally, but it widens blast radius beyond bulk-actions and races with other consumers; the snapshot fallback is the minimal, locally-consistent fix.
changed the title [-]Both Export to accounting options don't show in the bulk select menu until opening the report first.[/-][+][$250] Both Export to accounting options don't show in the bulk select menu until opening the report first.[/+]on Jun 8, 2026
In the bulk-select export logic, both "Export to [integration]" and "Mark as manually exported" are gated by canExportAllReportsToIntegration / canMarkAllReportsAsExported, which require selectedReports.every((report) => canReportBeExported(...)) (useSearchBulkActions.ts#L1183-L1192).
canReportBeExported looks up the report only in the live Onyx report collection:
Causal chain: after a cache clear/restart, the Search results snapshot (currentSearchResults.data) holds the report, but the live COLLECTION.REPORT key is empty until the report is fetched → opening the report triggers OpenReport, which populates allReports → only then is completeReport non-null and both options appear. Before that, canReportBeExported returns false for every selected report, so neither option is built (useSearchBulkActions.ts#L1241-L1263). This is the same "snapshot vs. live Onyx" gap already noted elsewhere in this file (e.g. the flattenedReportActions merge at #L502-L523).
What changes do you think we should make in order to solve the problem?
In canReportBeExported, fall back to the Search snapshot when the live report is missing, instead of bailing out:
The snapshot report carries the fields getSecondaryExportReportActions needs (state/status, isExportedToIntegration, etc.), so the options compute correctly without first opening the report. The same fallback should be applied to the allReports lookup inside handleExportAction (#L1203) so the "export again" confirmation is consistent.
What alternative solutions did you explore? (Optional)
Eagerly fetch full report data for selected reports (e.g. call OpenReport/metadata fetch when a report is selected in Search). This fixes the symptom but adds network round-trips and a visible delay, whereas the snapshot already contains what's needed — so the snapshot fallback is preferred.
The fix for this issue (#93297) caused a landscape-only bug: #101333
The report list got its own scroll area inside a modal that already scrolls in landscape, so on a phone held sideways either the last report names or the confirm button couldn't be reached. It's fixed in #102335.
Activity
MelvinBot commentedon Jun 8, 2026
Proposal
What is the root cause of that problem?
The two export-to-accounting options in the Search bulk-select menu are computed in
useSearchBulkActions, and their visibility reads from the live Onyx collections (policy_*andreport_*) instead of the Search snapshot (currentSearchResults.data).Two gates fail on a fresh load:
useSearchBulkActions.ts:1149-1154readspolicyfrompolicies(the liveuseOnyx(POLICY)collection at line 324) and callsgetConnectedIntegration(policy), which needspolicy.connections. The whole menu block at line 1194 is wrapped inif (connectedIntegration).canReportBeExportedat line 1166 readscompleteReportfromallReports(liveuseOnyx(REPORT)) and returnsfalseimmediately if it's missing.On a fresh load after clearing cache, the Search > Reports list hydrates the snapshot (
currentSearchResults.data["report_<id>"]/["policy_<id>"]) but does not write those reports/policies into the livereport_*/policy_*collections. So both gates evaluate against empty data and the options are hidden.Opening the report fires
openReport()(SearchMoneyRequestReportPage.tsx:208); theOpenReportresponse populates the livereport_<id>andpolicy_<id>.connections. On return to Search both gates now pass — which is exactly the "open it first" workaround in the report.The tell that this is the bug: the sibling transaction logic in the same hook already reads from the snapshot first and only falls back to live Onyx —
useSearchBulkActions.ts:273— but the export logic was never given that fallback.Evidence & data flow
getSecondaryExportReportActions→isExportAction/isMarkAsExportedAction(ReportSecondaryActionUtils.ts:469-558) both short-circuit ongetValidConnectedIntegration(policy), which inspectspolicy.connections.getConnectedIntegration/getValidConnectedIntegrationreadpolicy?.connections?.[integration](PolicyUtils.ts:1986-2031).connectionsis an optional field on Policy and is only hydrated by an API response.policy_*/report_*entries and is read elsewhere in this hook (e.g.useSearchBulkActions.ts:432-438) — butgetExportOptions/canReportBeExportedignore it and read live Onyx only.Flow: load Search → snapshot filled, live
report_*/policy_*empty → select approved report → both gates fail → options hidden. Open report →OpenReportpopulates livereport_<id>+policy_<id>.connections→ back to Search → gates pass → options appear.What changes do you think we should make in order to solve the problem?
Make the export-visibility logic read from the Search snapshot first, falling back to live Onyx — mirroring the pattern already used at
useSearchBulkActions.ts:273:canReportBeExported(lines 1165-1166), resolvecompleteReportandreportPolicyfromcurrentSearchResults.datafirst, thenallReports/policies.policyfrom the snapshot first as well sogetConnectedIntegration(policy)seesconnections.policy.connections(and theconfig.autoSyncit reads). If the backend Search response stripsconnectionsfrom the policy snapshot, the fix must instead live in the backend (extend the Search response to includepolicy.connections) — which is outside the App repo and would need an internal engineer. Worth confirming the snapshot shape for an approved report on a connected policy first.What alternative solutions did you explore? (Optional)
connections) into the livepolicy_*collection, so the existing live-Onyx checks pass. Outside the App repo.policyID. More requests; not preferred over the snapshot fallback.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/92976)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
KJ21-ENG commentedon Jun 8, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Spend > Reports, after connecting an accounting integration and selecting approved reports in the bulk-select menu, the report-level accounting export options such as "Export to NetSuite" and "Mark as manually exported" are missing until the user opens one of those reports first.
What is the root cause of that problem?
The bulk action menu is calculating report-level export eligibility from the full report entry in the
ONYXKEYS.COLLECTION.REPORTcollection, but the Spend > Reports search/list view can have the selected report available only as search result data after a cache clear.In
SearchContext, when a report-group row is selected,selectedReportsis built from the search list item. That list item is already aTransactionReportGroupListItemType, which extendsReport, but the selection state strips it down to a smaller object.Then
useSearchBulkActionsdecides whether to show the two integration export options withcanReportBeExported(). That helper does this:So on a cold cache, the report row can be visible and selected from the search snapshot, but if
allReports[reportID]has not been hydrated yet, bothcanExportAllReportsToIntegrationandcanMarkAllReportsAsExportedbecome false. Opening the report hydrates the full report Onyx entry, so the exact same bulk-selection path starts passing and the two options appear.What changes do you think we should make in order to solve the problem?
Make the report-level bulk export eligibility use the report data that is already available from the search/list result before falling back to the full Onyx report collection.
Concretely:
Preserve the selected report row's report data when building
selectedReportsinSearchContext, or otherwise keep enough of theReportfields on the selected report object for secondary action checks.In
useSearchBulkActions'scanReportBeExported(), resolve the report in this order:allReports[REPORT + reportID], when it exists;currentSearchResults.data[REPORT + reportID], when present;SearchContext.Pass that resolved report into
getSecondaryExportReportActions()instead of returning false just because the standalone report collection entry is missing.Keep the existing policy/accounting checks unchanged. The fix should only remove the artificial dependency on opening the report first; it should not make export actions appear for reports that
getSecondaryExportReportActions()would reject.Add regression coverage around the Spend > Reports bulk menu with an approved report whose search result exists but whose
ONYXKEYS.COLLECTION.REPORT + reportIDentry is not loaded. The test should verify that the integration export item and "Mark as manually exported" item are still included whengetSecondaryExportReportActions()would allow them, and that the normal non-eligible report cases remain hidden.What alternative solutions did you explore? (Optional)
Forcing the app to fetch or hydrate every selected report before opening the bulk menu would also make
allReports[reportID]exist, but it adds extra loading and keeps the UI coupled to a cache side effect. Using the already-loaded search result report is more direct and matches how the Reports list can render and select the report before the detail page has ever been opened.abbasifaizan70 commentedon Jun 8, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Spend > Reports, when an approved report is selected, the bulk‑select menu does not show the two accounting export options ("Export to NetSuite" and "Mark as manually exported") on a fresh load (after clearing cache and restarting). The options only appear after the user opens the report once and navigates back. They should be available immediately, without the user having to open the report first.
What is the root cause of that problem?
The bulk‑select export options are gated on whether the report exists in the full
report_Onyx collection (allReports), which is only populated for a report once that report has been opened (anOpenReportcall writes the full report intoreport_<reportID>). On a fresh load the report only lives in the Search snapshot, so the gate fails and both options are hidden.canReportBeExportedreads the report fromallReportsand returnsfalsewhen it is missing, instead of falling back to the Search snapshot the menu already has. This early return is the bug:App/src/hooks/useSearchBulkActions.ts
Lines 1160 to 1181 in bf9ef82
Both export options are computed by calling
canReportBeExportedfor every selected report, so when it returnsfalsefor an unopened report, neither "Export to integration" nor "Mark as manually exported" is added to the menu:App/src/hooks/useSearchBulkActions.ts
Lines 1183 to 1192 in bf9ef82
The eligibility check itself (
getSecondaryExportReportActions) only needs report fields that are already present in the Search snapshot —type,statusNum/stateNum,policyID,ownerAccountID, etc. It does not require any data that is exclusive to the opened‑report payload, so requiring the fullreport_entry is unnecessary:App/src/libs/ReportSecondaryActionUtils.ts
Lines 1088 to 1113 in bf9ef82
The same hook already establishes the correct pattern elsewhere — it reads the report from the Search snapshot first and falls back to
allReports— which is exactly the resilience missing incanReportBeExported:App/src/hooks/useSearchBulkActions.ts
Line 273 in bf9ef82
What changes do you think we should make in order to solve the problem?
All suggested code is TypeScript and only shows the lines that actually change.
Make
canReportBeExportedfall back to the Search snapshot (currentSearchResults?.data) when the full report is not yet inallReports, mirroring the existing pattern at line 273. The original block is shown by the permalink in the root cause above; the changed lines become:currentSearchResultsis already destructured in this hook (const {currentSearchResults} = useSearchResultsContext();) and is used throughoutgetExportOptions, so it is in scope and no new dependency is introduced. With the snapshot fallback,getSecondaryExportReportActionsreceives the report data on first render and both options appear without the report needing to be opened.A verification step should confirm: (1) on a fresh load both options appear for an approved report; (2) the options remain correct after the report is opened (where
allReportsnow takes precedence, preserving the freshest data); and (3) non‑exportable reports (e.g. open/processing, no connection) still correctly hide the options.What alternative solutions did you explore? (Optional)
Use the
reportargument (the selected snapshot report) directly instead of re‑derivingcompleteReport.canReportBeExportedalready receives the selected report object, so it could passreportstraight intogetSecondaryExportReportActions. Rejected as the primary fix because keeping theallReportslookup as the preferred source ensures the freshest data once a report has been opened/updated; the snapshot is used only as a fallback. (Functionally close to the proposed fix, but the snapshot‑fallback form is more consistent with line 273.)Prefetch the full reports via
OpenReportwhen the Reports search results load. This would populateallReportsso the existing gate passes. Rejected because it fires N network requests just to render a menu, defeats the purpose of the Search snapshot, and adds latency and load for what is purely a client‑side eligibility check.Relax the gate by removing the
if (!completeReport) return false;guard and computing options from whatever data is available. Rejected because it risksgetSecondaryExportReportActionsreceiving anundefinedreport and could surface options for ineligible reports; the snapshot fallback keeps a validReportobject flowing into the check.melvin-bot commentedon Jun 8, 2026
Current assignee @ahmedGaber93 is eligible for the External assigner, not assigning anyone new.
aswin-s commentedon Jun 8, 2026
Please re-state the problem that we are trying to solve in this issue.
On Web (Spend > Reports), after a fresh cache + restart, selecting an approved report does not show the "Export to NetSuite" or "Mark as manually exported" options in the bulk select menu. The options only appear after the user opens the report once and goes back. Expected: both options should be available without having to open the report first.
What is the root cause of that problem?
getExportOptionsinuseSearchBulkActions.tsderives the workspace policy from the Onyx collection at two distinct points, and both fail on a cold load:Point 1 —
connectedIntegrationgate (line ~1149–1154).policyis resolved as:The entire export submenu is wrapped in
if (connectedIntegration). On a fresh loadONYXKEYS.COLLECTION.POLICYhas not yet hydrated, sopolicyisundefined,connectedIntegrationisundefined, and theifbranch is never entered — neither option is rendered at all.Point 2 —
canReportBeExportedpredicate (lines ~1160–1181). Inside the predicate,completeReportandreportPolicyare resolved exclusively from the Onyx collections:On a fresh load the report exists in the search snapshot (
currentSearchResults.data) — which is why it renders in the list — but its full record has not yet been hydrated intoONYXKEYS.COLLECTION.REPORT. WithcompleteReportundefined, the predicate returnsfalseearly, socanExportAllReportsToIntegrationandcanMarkAllReportsAsExportedare both false even if theconnectedIntegrationgate were somehow passed. Opening the report hydrates both Onyx collections, after which both guards pass — matching the reproduction exactly.What changes do you think we should make in order to solve the problem?
Three targeted edits to
src/hooks/useSearchBulkActions.ts, all withingetExportOptions:1. Add a snapshot fallback when deriving
policy(fixes theconnectedIntegrationgate, line ~1149).This ensures
getConnectedIntegration(policy)returns the integration name even beforeONYXKEYS.COLLECTION.POLICYhas hydrated, so theif (connectedIntegration)branch is entered and the options are rendered.2. Add snapshot fallbacks inside
canReportBeExportedfor bothcompleteReportandreportPolicy(fixes the predicate, lines ~1165–1166).This mirrors the pattern already used elsewhere in this same file — for example,
shouldShowBulkDuplicateOption'sgetReportOrDraftReport(reportID, searchReports)usage and the duplicate-option block at line 273 — where the search snapshot is consulted as a fallback for the Onyx collection. With a realcompleteReport,getSecondaryExportReportActionscan determine eligibility, and with a realreportPolicyit receives the connection info needed to do so.3. No dependency array change needed.
currentSearchResults?.datais already present in theheaderButtonsOptionsuseMemodependency array, so no additional wiring is required.4. No platform twin needed — the hook is shared and the issue is reported on Web/MacOS Chrome only; the same code path runs on all platforms.
What alternative solutions did you explore? (Optional)
Eagerly hydrating selected reports into
ONYXKEYS.COLLECTION.REPORTon selection would fix it globally, but it widens blast radius beyond bulk-actions and races with other consumers; the snapshot fallback is the minimal, locally-consistent fix.[-]Both Export to accounting options don't show in the bulk select menu until opening the report first.[/-][+][$250] Both Export to accounting options don't show in the bulk select menu until opening the report first.[/+]melvin-bot commentedon Jun 8, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022064112439939852919
lorretheboy commentedon Jun 8, 2026
Proposal
What is the root cause of that problem?
In the bulk-select export logic, both "Export to [integration]" and "Mark as manually exported" are gated by
canExportAllReportsToIntegration/canMarkAllReportsAsExported, which requireselectedReports.every((report) => canReportBeExported(...))(useSearchBulkActions.ts#L1183-L1192).canReportBeExportedlooks up the report only in the live Onyx report collection:(
useSearchBulkActions.ts#L1166-L1170)Causal chain: after a cache clear/restart, the Search results snapshot (
currentSearchResults.data) holds the report, but the liveCOLLECTION.REPORTkey is empty until the report is fetched → opening the report triggersOpenReport, which populatesallReports→ only then iscompleteReportnon-null and both options appear. Before that,canReportBeExportedreturnsfalsefor every selected report, so neither option is built (useSearchBulkActions.ts#L1241-L1263). This is the same "snapshot vs. live Onyx" gap already noted elsewhere in this file (e.g. theflattenedReportActionsmerge at#L502-L523).What changes do you think we should make in order to solve the problem?
In
canReportBeExported, fall back to the Search snapshot when the live report is missing, instead of bailing out:The snapshot report carries the fields
getSecondaryExportReportActionsneeds (state/status,isExportedToIntegration, etc.), so the options compute correctly without first opening the report. The same fallback should be applied to theallReportslookup insidehandleExportAction(#L1203) so the "export again" confirmation is consistent.What alternative solutions did you explore? (Optional)
Eagerly fetch full report data for selected reports (e.g. call
OpenReport/metadata fetch when a report is selected in Search). This fixes the symptom but adds network round-trips and a visible delay, whereas the snapshot already contains what's needed — so the snapshot fallback is preferred.44 remaining items
melvin-bot commentedon Jun 25, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Jun 25, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
ahmedGaber93 commentedon Jun 25, 2026
@mallenexpensify The second PR here is not a regression. We split this issue into two PRs because each PR addressed a different root cause.
Expected bounty: $250
mallenexpensify commentedon Jun 28, 2026
Payment Summary
Contributor+: @ahmedGaber93 due $500 via NewDot
Thx for note, looks accurate. ^ Test case created. Thx
flaviadefaria commentedon Jul 31, 2026
Approved: @ahmedGaber93 due $500 via NewDot
TaduJR commentedon Sep 30, 2026
The fix for this issue (#93297) caused a landscape-only bug: #101333
The report list got its own scroll area inside a modal that already scrolls in landscape, so on a phone held sideways either the last report names or the confirm button couldn't be reached. It's fixed in #102335.