Skip to content

Use one export rule across the to-do, the sidebar and the report page - #102953

Merged
mountiny merged 23 commits into
Expensify:mainfrom
dukenv0307:unify-export-rule
Oct 30, 2026
Merged

mountiny merged 23 commits into
Expensify:mainfrom
dukenv0307:unify-export-rule

Conversation

@dukenv0307

@dukenv0307 dukenv0307 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Read the exporter from the connections like the server does, and skip reports that are archived, queued for export, or cash-basis and not yet paid.

Fixed Issues

$ #102868
BE PR: https://github.com/Expensify/Auth/pull/25129, https://github.com/Expensify/Auth/pull/25628

Tests

  1. Sign in as an admin on a Collect/Control workspace with an accounting integration connected (QuickBooks Online, Xero or Sage Intacct).
  2. Go to Workspace → Accounting → Advanced and set:
    • Auto-sync: off
    • Accounting method: select Accrual first, then re-select Cash.
  3. In the integration's export settings, confirm the Preferred exporter is your own account.
  4. Create an expense on that workspace, submit it, and approve it. Do not pay it.
  5. Open Home and look at the To-dos list.
    • Expected: there is no "Export 1 report" row for this report.
  6. Open Reports (Spend) and search type:expense-report action:export exported:never exporter:me.
    • Expected: no results — the same answer as the to-do.
  7. Pay the report.
  8. Reload Home and re-run the same search.
  9. Verify that the report now appears in both — "Export 1 report" on Home, and 1 result in the search.
  • Verify that no errors appear in the JS console

Offline tests

Same as above

QA Steps

Same as above

  • 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)
  • 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari Screenshot 2026-10-03 at 11 17 52 Screenshot 2026-10-03 at 11 19 41 Screenshot 2026-10-03 at 11 18 00

@dukenv0307 dukenv0307 changed the title Use one export rule across the to-do, the sidebar and the report page [Hold BE] Use one export rule across the to-do, the sidebar and the report page Oct 5, 2026
@dukenv0307

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-21T22:37:53.687728Z
We couldn’t complete this review. Comment @codex review to try again.
8de29f4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Oct 13, 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 95.90% <ø> (ø)
src/libs/ReportPreviewActionUtils.ts 92.56% <100.00%> (+0.12%) ⬆️
src/libs/ReportPrimaryActionUtils.ts 95.52% <100.00%> (+0.50%) ⬆️
src/libs/ReportUtils.ts 90.07% <100.00%> (+0.09%) ⬆️
src/libs/SearchUIUtils.ts 73.72% <100.00%> (-0.02%) ⬇️
src/libs/TodosUtils.ts 97.14% <100.00%> (ø)
src/libs/ReportActionsUtils.ts 84.40% <50.00%> (-0.03%) ⬇️
src/libs/PolicyUtils/connections.ts 95.77% <91.66%> (-2.10%) ⬇️
... and 4 files with indirect coverage changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c927d9ab2

ℹ️ 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".

Comment thread tests/unit/TodosUtilsTest.ts Resolved
Comment thread src/libs/ReportPrimaryActionUtils.ts Resolved
Comment thread src/libs/ReportPrimaryActionUtils.ts Resolved
Comment thread src/libs/ReportUtils.ts Resolved
@dukenv0307

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 920bf86e10

ℹ️ 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".

Comment thread src/libs/ReportPrimaryActionUtils.ts Resolved
Comment thread src/libs/ReportPrimaryActionUtils.ts Resolved
@dukenv0307
dukenv0307 marked this pull request as ready for review October 13, 2026 04:05
@dukenv0307
dukenv0307 requested review from a team as code owners October 13, 2026 04:05
@melvin-bot
melvin-bot Bot requested review from joekaufmanexpensify and situchan and removed request for a team October 13, 2026 04:05
@melvin-bot

melvin-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

@situchan 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team October 13, 2026 04:05
Comment thread src/libs/ReportUtils.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b3aa80d9f

ℹ️ 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".

Comment thread src/libs/ReportUtils.ts Resolved
@dukenv0307 dukenv0307 changed the title [Hold BE] Use one export rule across the to-do, the sidebar and the report page Use one export rule across the to-do, the sidebar and the report page Oct 13, 2026

@joekaufmanexpensify joekaufmanexpensify left a comment

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.

Good for product

@mountiny mountiny left a comment

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.

(Vit's agent) I compared this PR with the backend rules in https://github.com/Expensify/Auth/pull/25129 and https://github.com/Expensify/Auth/pull/25628, one clause at a time. These all match Auth: the export failure check (only the latest integration message counts, and not one from before the last approval reset), the queued check, the archive check, and the cash basis rule for card only reports, including closed and empty reports. I found no blockers in the code.

Please fix these before merge:

  1. The QA steps fail on a new connection. A newly connected QBO, Xero or Intacct has no accountingMethod key. The settings page shows Cash for that state (DynamicQuickbooksOnlineAccountingMethodPage.tsx:37). getIntegrationAccountingMethod and Auth both read it as Accrual. A tester who sees Cash already selected does not change it, so step 5 shows the to-do. @situchan hit this. Please change step 2 to: select Accrual, then select Cash again, so the key is saved.
  2. The card only rule has no tests. See the inline comment on isCardOnlyReport.
  3. The file docblock in connections.ts still sits on the expensify-common import (from @situchan's thread). Move it back to line 1.
  4. The exporter list does not match Auth for Zoho Books and Business Central. See the inline comment on getConnectionExporters.

Follow-up, not for this PR: an unset accountingMethod has three defaults across the stack.

  • The App settings pages show Cash.
  • Integration-Server uses Cash when ACH reimbursement is on, and Accrual otherwise (QuickbooksOnlineReportExporterHelper.java:4427; the NetSuite, QBD, Xero and Intacct exporters do the same).
  • Auth search and this PR use Accrual.

This PR keeps the to-do and the search in step with each other, so it is not a regression. But the settings page, the exporter and the to-do can still disagree about which method a workspace uses. I think that answers @situchan's question about fixing it separately: yes, in its own issue.

Comment thread src/libs/ReportUtils.ts Resolved
Comment thread src/libs/PolicyUtils/connections.ts Resolved
Comment thread src/CONST/index.ts Resolved
@mountiny

Copy link
Copy Markdown
Contributor

@dukenv0307 can you address the review please?

@dukenv0307
dukenv0307 requested a review from mountiny October 23, 2026 09:33
mountiny
mountiny previously approved these changes Oct 23, 2026

@mountiny mountiny left a comment

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.

Looks good to me, thanks for the changes, just one small nit

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.

the tests should have Given, When, Then comments

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.

Added // Given, // When and // Then comments to every test this PR adds or changes, in bc4f581:

  • tests/actions/ReportPreviewActionUtilsTest.ts
  • tests/unit/ReportPrimaryActionUtilsTest.ts
  • tests/unit/TodosUtilsTest.ts
  • tests/unit/useTodoCountsTest.tsx

Each comment says why the test expects what it does. Test logic is unchanged.


view run

@mountiny

Copy link
Copy Markdown
Contributor

oh no conflicts

@dukenv0307

Copy link
Copy Markdown
Contributor Author

@MelvinBot Fix #102953 (comment) and resolve conflict

MelvinBot and others added 3 commits October 26, 2026 01:55
Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>

# Conflicts:
#	src/libs/SearchUIUtils.ts
Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>
Co-authored-by: Nguyen Van Duc <dukenv0307@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor

I fixed the Given/When/Then review comment and resolved the merge conflict with main.

  • Conflict: src/libs/SearchUIUtils.ts in getSuggestedSearchesVisibility. I kept main's new isPaymentsAdmin and this PR's isPreferredExporter check for isExporter.
  • Review comment: Every test this PR adds or changes now has // Given, // When and // Then comments. That covers ReportPreviewActionUtilsTest, ReportPrimaryActionUtilsTest, TodosUtilsTest and useTodoCountsTest.
  • Seatbelt: ESLint lowered the no-unsafe-type-assertion count for SearchUIUtils.ts from 71 to 70. I committed that update.

Checks I ran: the five affected Jest suites pass (819 tests), and npm run typecheck and npm run lint-changed pass.


view run

@dukenv0307
dukenv0307 requested a review from mountiny October 26, 2026 02:02
@dukenv0307

Copy link
Copy Markdown
Contributor Author

@mountiny All yours!

@dukenv0307

Copy link
Copy Markdown
Contributor Author

@mountiny Is it good to merge 🤔 ?

@mountiny mountiny left a comment

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.

Yes! Sorry i was ooo

@mountiny
mountiny merged commit 692601c into Expensify:main Oct 30, 2026
47 of 69 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.27-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed. This is a bug fix that makes the Export to-do, report actions, and export search match the server's existing rules, and no help article describes the cases it changes, such as unpaid cash-basis reports or reports already queued for export.


view run

@m-natarajan

Copy link
Copy Markdown

@dukenv0307 This PR is failing because of a regression issue #102868 (comment)

@situchan

situchan commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

I set accountingMethod by manually switching to Accrual and then back to Cash.

@m-natarajan please follow #102953 (comment). It's pre-condition for new accounts.

@dukenv0307 QA faced the same bug as I reported. I think we should fix this in a new issue.

@OSBotify

OSBotify commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/blimpich in version: 9.5.27-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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.

7 participants