Skip to content

Preserve expense workspace when creating a report from workspace chat - #107946

Merged
Gonals merged 2 commits into
mainfrom
claude-preserveExpenseWorkspace
Dec 2, 2026
Merged

Gonals merged 2 commits into
mainfrom
claude-preserveExpenseWorkspace

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Apply the changes requested by ZhenjaHorbach so Create report preserves the originating workspace during non-global expense creation instead of unexpectedly switching to the default workspace. Preserve existing global-create, own-expense editing, per-diem, and other-owner behavior.

Add the three requested regression tests. The non-default-workspace test fails with the original condition and passes with the change.

AI Tests

Initial implementation validation (before the November 27 main merge):

  • Passed: 20 tests across 5 targeted Jest suites (report-picker actions, workspace resolution, both report-step suites, and report-picker modal).
  • Passed: lint on both changed files, full npm run typecheck, spelling, React Compiler compliance for the changed hook, and npm run storybook -- --smoke-test --ci.
  • Passed: Oxfmt on both changed files via the repository's pre-commit hook. This checkout has no prettier npm script.
  • Passed: staged-diff code review; no violations reported.
  • Full repository Jest suite was not run. Jest emitted existing duplicate-manual-mock warnings.
  • Web verification on November 25: workspace-chat creation, global creation, and own-expense editing passed; console inspection was unavailable. See the web verification results.
  • After merging main on November 27: all 3 report-picker regression tests, lint, and Storybook smoke test passed. Typecheck reported two errors in unchanged upstream code; formatting verification was blocked by tool permissions. See the post-merge validation results.
  • No tests were rerun for this description-only update. The earlier blank-page screenshot below records the initial blocked attempt, not the later successful web verification.

Development app displaying a blank page

Contributor branch access

This draft uses an upstream branch because Melvin cannot push to ZhenjaHorbach's fork. To copy it to your fork:

git remote add upstream https://github.com/Expensify/App.git
git fetch --depth=1 upstream claude-preserveExpenseWorkspace
git checkout -b claude-preserveExpenseWorkspace FETCH_HEAD
git push -u origin claude-preserveExpenseWorkspace

You can then close this draft and open a PR from your fork if you prefer to push updates there.

Fixed Issues

$ #107683
PROPOSAL: #107683 (comment)

Tests

Repeatable test cases (expected results below are not claims of fresh execution). The first three flows passed on development web before the main merge; only the automated regression tests were rerun after the merge. See AI Tests for evidence and limitations.

  1. Non-default workspace: Sign in with workspace A set as Default and workspace B non-default. Create at least two open reports in each workspace. Open B's expense chat without changing the default workspace. Use the chat composer + → Create expense → Manual, enter a valid amount, merchant, and date, then open Report. Verify the listed reports and Create report target B. Select Create report, finish saving the expense, and verify both the new report and saved expense belong to B, not A.
  2. Global-create regression: With A still Default, start a manual expense from the global create menu. Open Report → Create report, complete the expense, and verify the new report uses A rather than forcing B.
  3. Own-expense editing regression: Open one of your existing non-per-diem expenses in B and edit its Report. Verify Create report uses the default workspace A; selecting it moves the expense into a new report in A.
  4. Workspace without an existing expense report — pending: Start a manual expense from a new non-default workspace's expense chat. Select Report → Create report and verify the new report stays in that workspace.
  5. Per-diem and other-owner regressions — pending: Where account permissions and enabled features allow, change the report of a per-diem expense and an expense owned by another member. Verify Create report preserves the expense's original workspace.
  6. Cancel and validation — pending: Open B's report picker and go back without changing the selection; verify the expense remains in B with its previous selection intact. Try saving a manual expense with a required field missing; verify submission is blocked with the appropriate validation message. Correct the field and verify saving to a new B report succeeds.
  7. Console — pending: Monitor the JavaScript console throughout these flows and verify there are no new errors attributable to this change.
  • Verify that no errors appear in the JS console

Offline tests

Pending execution:

  1. While online, load A and B and their open reports. Keep A as Default, then open B's expense chat.
  2. Disconnect the network. Start a manual expense from B and open Report → Create report. Verify the workspace remains B and the optimistic report/expense is retained locally after saving.
  3. Reconnect and verify synchronization completes without duplicate reports/expenses or a switch to A.
  4. Repeat global creation and own-expense report editing offline; verify their default-workspace behavior is unchanged after reconnecting.

QA Steps

Run the numbered Tests cases and Offline tests above on staging once this change is available there. Cover native Android/iOS, mobile web, and desktop Chrome/Safari, including a narrow viewport. Confirm the initial-workspace fix and the global-create, own-expense editing, per-diem, and other-owner regressions. These staging/platform runs remain pending; the existing development-web results do not certify all platforms.

  • Verify that no errors appear in the JS console

PR Author Checklist

Checklist status: Checked items are supported by the linked evidence or the test instructions added here. Conditional items checked below are not applicable: this PR changes workspace-selection logic and adds regression tests; it adds no user-facing copy, new code pattern, assets, message formatting, generic component, Storybook component, deeplink, visual layout, form styling, or interactive UI. Unverified execution items remain unchecked, including offline/high-traffic/all-platform testing, console inspection, accessibility execution, and post-merge manual retesting. Earlier Android verification was partial; development web did not establish macOS Chrome/Safari coverage.

  • 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 verified any copy / text that was added to the app 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 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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

Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>
@MelvinBot

MelvinBot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Android test steps verification results: ⚠️ partial

Verified the main fix on standalone Android NewDot: creating a manual expense from non-default B retained B for report selection, new report creation, and the saved expense. The tester reached its step limit; global-create, editing, and console checks remain incomplete.
New Workspace B report containing the saved manual expense

Step Status
1. Open the native Android appApp opened, signed in, and onboarded.
✅
2. Prepare two workspaces with two open reports eachCreated two draft reports in each workspace. A was identified as Default; B was non-default.
✅
3. Navigate to B’s expense chatOpened B’s chat without changing default workspace A.
✅
4. Chat + → Create expense → ManualFollowed the chat action menu. The expense form identified Workspace B.
✅
5. Report picker targets BBoth existing reports and Create report displayed Workspace B.
Report picker showing B's existing reports and Create report targeting B
✅
6. Create report preserves BCreated the report and saved a $12.34 expense. The new report belonged to B; B’s chat showed the expense.
New Workspace B report containing the saved manual expense
✅
7. Global-create retains default behaviorIncomplete: global report creation targeted A during setup, but the global expense-create regression was not tested.
❌
8. Editing an own expense retains default behaviorUntested: tester step limit reached.
❌
9. Verify no JS console errorsUnverified: logs were captured but not inspected before the step limit.
❌

view run · view recording

@MelvinBot

MelvinBot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Web test steps verification results: ⚠️ partial

Steps 1–8 passed on development NewDot web: creating an expense from B preserved B, while global creation and editing retained default workspace A behavior. Console verification remains blocked.
Existing expense moved into a new default Workspace A report

Step Status
1. Open the development web buildApp loaded with a signed-in account and completed onboarding.
✅
2. Prepare two workspaces with two open reports eachConfirmed A’s Default label, created non-default B, and created two empty reports per workspace.
✅
3. Navigate to B’s expense chatOpened B’s expense chat without changing default workspace A.
✅
4. Composer + → Create expense → ManualFollowed the composer menu; the expense form showed Workspace B.
✅
5. Report choices and Create report target BBoth existing reports and Create report identified Workspace B.
B-chat report picker showing two B reports and Create report targeting B
✅
6. New report and expense remain in BSelected Create report and saved the $12.34 expense. Its new report linked to Workspace B.
Created expense and new report in Workspace B
✅
7. Global expense creation retains default behaviorGlobal creation targeted A. Selected Create report and saved a $23.45 expense in a new Workspace A report.
Global expense creation targeting default Workspace A
Globally created expense saved in a new Workspace A report
✅
8. Editing an own expense retains default behaviorOpened Report on the existing B expense. Create report targeted A; selecting it moved the expense into a new Workspace A report.
Existing expense moved into a new default Workspace A report
✅
9. Verify no JavaScript console errorsBlocked: console inspection is unavailable through the supported testing interface. No clean-console verdict is claimed.
⚠️

view run · view recording

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Update the branch to the latest version of main

Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Updated the branch with the latest main and pushed 7243b96. No conflicts.

Validation: all 3 regression tests, lint, and Storybook smoke test passed. Typecheck reported two errors in unchanged upstream code; formatting verification was blocked by tool permissions.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ Something went wrong. This may be a transient issue. Try again. If it persists, check status.openai.com.

Run details

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Open the PR

@MelvinBot
MelvinBot marked this pull request as ready for review November 30, 2026 11:45
@MelvinBot
MelvinBot requested a review from a team as a code owner November 30, 2026 11:45
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Marked the PR as ready for review.


view run

@expensify-chore-bot
expensify-chore-bot Bot requested review from ZhenjaHorbach and flaviadefaria and removed request for a team November 30, 2026 11:45
@expensify-chore-bot

Copy link
Copy Markdown

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-30T11:49:40.366245Z 7243b96 Draft marked ready
ℹ️ 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.

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Add test cases in the PR description and complete the checklist

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Added regression, validation, offline, and QA test cases to the PR description. Updated the author checklist, marking supported or not-applicable items complete and leaving unverified testing items unchecked with explanations.


view run

@ZhenjaHorbach

ZhenjaHorbach commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app 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 verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-12-01.at.13.57.57.mov
Android: mWeb Chrome
Screen.Recording.2026-12-01.at.13.57.57.mov
iOS: HybridApp
Screen.Recording.2026-12-01.at.13.42.32.mov
iOS: mWeb Safari
Screen.Recording.2026-12-01.at.13.42.32.mov
MacOS: Chrome / Safari
Screen.Recording.2026-12-01.at.13.27.00.mov
Screen.Recording.2026-12-01.at.13.27.51.mov
Screen.Recording.2026-12-01.at.13.30.45.mov

@melvin-bot

melvin-bot Bot commented Dec 1, 2026

Copy link
Copy Markdown

We did not find an internal engineer to review this PR, trying to assign a random engineer to #107683 as well as to this PR... Please reach out for help on Slack if no one gets assigned!

@expensify-chore-bot
expensify-chore-bot Bot requested a review from Gonals December 1, 2026 12:59
@Gonals
Gonals merged commit 3bb9399 into main Dec 2, 2026
65 of 70 checks passed
@Gonals
Gonals deleted the claude-preserveExpenseWorkspace branch December 2, 2026 12:19
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Dec 2, 2026

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.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

@OSBotify OSBotify mentioned this pull request Dec 3, 2026
81 of 100 tasks
@OSBotify

OSBotify commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/Gonals in version: 9.5.58-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No help site update needed — this bug fix keeps newly created reports in the originating workspace when adding an expense from its chat, restoring expected behavior without introducing a new workflow or making existing instructions incorrect.


view run

@jponikarchuk

Copy link
Copy Markdown

@ZhenjaHorbach Could you please clarify the step 4? It says to “Select Report → Create report,” but in a brand new non-default workspace, the Report field isn’t selectable at all. It seems expected since there are no open reports there. Should “Create report” still appear as an option?
image (14)

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

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants