Skip to content

fix: pass workspace policyID only for GL-code export templates#94389

Draft
aswin-s wants to merge 1 commit into
Expensify:mainfrom
aswin-s:fix/issue-89388-glcode-scoped
Draft

fix: pass workspace policyID only for GL-code export templates#94389
aswin-s wants to merge 1 commit into
Expensify:mainfrom
aswin-s:fix/issue-89388-glcode-scoped

Conversation

@aswin-s

@aswin-s aswin-s commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This re-raises #92131 (reverted in #93091) with a narrowed scope so it $ #89388 without re-introducing deploy blocker #93088.

Account-level export templates have policyID: undefined by design (returned by getExportTemplates). #92131 attached the selection's workspace policyID to every account-level template. The backend only needs a workspace policyID to resolve GL codes (e.g. {expense:category:glcode}); for plain {expense:category}/{expense:tag} account-level templates, sending a policyID made the backend fail to generate the file — the optimistic "Export in progress" message showed but nothing reached Concierge (#93088).

This PR scopes the workspace policyID to only templates that reference GL codes (a column containing :glcode):

Changes:

  • src/libs/actions/Search.ts: new exported helper doesExportTemplateRequireWorkspacePolicy(template)true only when a column contains the GL-code marker.
  • src/hooks/useSearchBulkActions.ts: bulk path resolves the workspace policyID only when the template requires GL codes. The multi-workspace guard is preserved — it falls back to the selection's workspace only when every selected transaction belongs to a single real workspace, otherwise policyID is left undefined.
  • src/hooks/useExportActions.ts: single-report path falls back to moneyRequestReport.policyID only for GL-code templates.
  • src/types/onyx/ExportTemplate.ts: added columns?: string[] (already present at runtime).
  • src/CONST/index.ts: added the :glcode column marker constant.

Fixed Issues

$ #89388
PROPOSAL: #89388 (comment)

Tests

Preconditions:

  • An account-level custom export template (created in Classic via Settings → Account → Preferences → CSV Export Formats, or Reports → Export to → Create new CSV export layout — not a workspace-scoped Export Format) containing a column with the formula {expense:category:glcode} or {expense:tag:glcode} — call this the GL-code account template.
  • A second account-level template with only plain {expense:category} / {expense:tag} columns (no :glcode) — call this the plain account template.
  • A workspace-level export template (created inside a workspace's Export Formats) — call this the workspace template.
  • A workspace with GL codes assigned to at least one category or tag, and expenses on that workspace categorized/tagged accordingly.

A. GL-code account template — bulk path (useSearchBulkActions):

  1. Go to Search → Expenses, filter to the single workspace that has GL codes, select expenses, and Export using the GL-code account template.
  2. Verify the export completes and the file is delivered to Concierge with the correct GL codes (matching Classic Expensify output).
  3. (Definitive) With DevTools → Network, inspect the QueueExportSearchWithTemplate request body — policyID is present and matches the workspace ID.
  4. Repeat with a selection that spans multiple workspaces and verify the export completes without errors (policyID is intentionally absent; GL codes may be unresolved by design for multi-workspace selections).

B. Plain account template — bulk path (regression guard for #93088): 5. Select expenses on the same workspace and Export using the plain account template. 6. Verify the file is delivered to Concierge (does not silently fail). 7. (Definitive) Inspect the QueueExportSearchWithTemplate request — policyID is absent.

C. Workspace template — bulk path: 8. Select expenses and Export using the workspace template. 9. Verify the file is delivered (policyID present = the template's own workspace ID — unchanged behavior).

D. Single-report path (useExportActions): 10. Open an expense report on the workspace with GL codes → report header menu → Export. 11. Export with the GL-code account template → verify the file has the correct GL codes (request includes policyID). 12. Export with the plain account template → verify the file is delivered (request has no policyID).

  • Verify that no errors appear in the JS console

Offline tests

  1. Turn off network connection.
  2. Attempt to export using a custom template.
  3. Verify the offline modal appears and no export is triggered.

QA Steps

Preconditions (same as Tests):

  • An account-level GL-code template with a {expense:category:glcode} / {expense:tag:glcode} column.
  • An account-level plain template with only {expense:category} / {expense:tag} columns.
  • A workspace-level template.
  • A workspace with GL codes set on categories/tags, and expenses categorized/tagged accordingly.

Account-level templates (Search/Expenses bulk export):

  1. Go to Search → Expenses, filter to the single workspace with GL codes, select expenses.
  2. Export using the GL-code account template → verify the file is delivered to Concierge with correct GL codes matching Classic Expensify.
  3. Export using the plain account template → verify the file is delivered to Concierge (this is the Export - Custom export template file is not delivered to Concierge #93088 regression check — it must not silently fail).
  4. Repeat step 2 with a multi-workspace selection → verify the export still completes without errors.

Workspace-level template (Search/Expenses bulk export): 5. Select expenses and Export using the workspace template → verify the file is delivered.

Single-report export: 6. Open an expense report on the GL-code workspace → report header → Export → GL-code account template → verify correct GL codes. 7. Same report → Export → plain account template → verify the file is delivered.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native

CSV files can be verified on desktop only

Android: mWeb Chrome

CSV files can be verified on desktop only

iOS: Native

CSV files can be verified on desktop only

iOS: mWeb Safari

CSV files can be verified on desktop only

MacOS: Chrome / Safari

Account-level export templates have policyID undefined by design. The
previous fix (Expensify#92131) attached the selection's workspace policyID to every
account-level template, which broke file generation for plain
{expense:category}/{expense:tag} templates (deploy blocker Expensify#93088).

Scope the workspace policyID fallback to templates that actually reference
GL codes (a :glcode column). GL-code templates get the policyID they need
to resolve codes (fixes Expensify#89388); plain templates keep policyID undefined
and remain on the original working path.
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

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.

Files with missing lines Coverage Δ
src/CONST/index.ts 93.84% <ø> (ø)
src/hooks/useExportActions.ts 0.00% <0.00%> (ø)
src/libs/actions/Search.ts 38.40% <0.00%> (-0.16%) ⬇️
src/hooks/useSearchBulkActions.ts 55.36% <0.00%> (-0.50%) ⬇️
... and 12 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant