Skip to content

[Commuter Exclusion] Allow editing historical distance expenses - #98368

Merged
Gonals merged 9 commits into
Expensify:mainfrom
fedirjh:fix/98223-edit-existing-distance
Sep 10, 2026
Merged

[Commuter Exclusion] Allow editing historical distance expenses#98368
Gonals merged 9 commits into
Expensify:mainfrom
fedirjh:fix/98223-edit-existing-distance

Conversation

@fedirjh

@fedirjh fedirjh commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Manual and odometer distance expenses created before commuter exclusions were enabled were blocked from being edited because the guard only checked the workspace's current settings. This change lets existing distance expenses bypass that creation guard.

Commuter exclusions are still not applied retroactively: transaction recalculation only updates exclusion data when the expense already has an applied exclusion. Creating a new manual or odometer expense in a workspace with commuter exclusions remains blocked.

Fixed Issues

$ #98223
PROPOSAL: #98223 (comment)

Tests

Prerequisite:

  • Have accounts with commuter exclusion beta enabled
  1. Create a manual distance expense in a workspace without commuter exclusions.
  2. Enable "Exclude fixed distance" in the workspace's distance settings.
  3. Open the existing expense, edit its distance, and save it.
  4. Verify the distance is updated without showing the map/GPS-required modal.
  5. Verify no commuter exclusion is applied to the edited expense.
  • Verify that no errors appear in the JS console

Offline tests

  1. Disconnect from the network.
  2. Edit a manual or odometer distance expense created before commuter exclusions were enabled.
  3. Verify the edit is allowed and the updated distance is shown optimistically without a commuter exclusion.
  4. Reconnect and verify the expense remains updated.

QA Steps

Same as tests.

  • 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 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 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

MacOS: Chrome / Safari
CleanShot.2026-08-24.at.11.59.45.mp4

@fedirjh fedirjh changed the title [Commuter Exclusion] Allow editing historical distance expenses [Hold] [Commuter Exclusion] Allow editing historical distance expenses Aug 24, 2026
@fedirjh
fedirjh requested a review from Gonals August 24, 2026 11:21
@fedirjh fedirjh changed the title [Hold] [Commuter Exclusion] Allow editing historical distance expenses [Commuter Exclusion] Allow editing historical distance expenses Sep 2, 2026
@fedirjh
fedirjh marked this pull request as ready for review September 2, 2026 13:01
@fedirjh
fedirjh requested review from a team as code owners September 2, 2026 13:01
@melvin-bot
melvin-bot Bot requested review from joekaufmanexpensify and removed request for a team September 2, 2026 13:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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 Completed 2026-09-02T13:13:18.351768Z a2ce86c 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.

@melvin-bot
melvin-bot Bot requested review from mjasikowski and removed request for a team September 2, 2026 13:01
@melvin-bot

melvin-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

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

@marufsharifi

marufsharifi commented Sep 2, 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 proper code patterns were followed (see Reviewing the code)
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • 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 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 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.
  • 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-09-02.at.9.22.43.PM.mov
Android: mWeb Chrome
Screen.Recording.2026-09-02.at.7.00.50.PM.mov
iOS: HybridApp
Screen.Recording.2026-09-02.at.9.15.31.PM.mov
iOS: mWeb Safari
Screen.Recording.2026-09-02.at.6.57.23.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-02.at.6.52.29.PM.mov

@marufsharifi

Copy link
Copy Markdown
Contributor
  1. Create a manual distance
  2. Go to distance rate > enable the Require GPS
  3. Go back to expense > edit the distance

Bug: Editing the distance does not show the Model require GPS and the distance is edited successfully

RF-1.mov

@marufsharifi

Copy link
Copy Markdown
Contributor

@fedirjh, could you please take a look at this #98368 (comment), thanks.

@JmillsExpensify JmillsExpensify 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.

LGTM

@joekaufmanexpensify
joekaufmanexpensify removed their request for review September 4, 2026 13:57
@fedirjh

fedirjh commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Bug: Editing the distance does not show the Model require GPS and the distance is edited successfully

@marufsharifi Why is this considered a bug? This looks like expected behavior — the distance was created before GPS enforcement was turned on, so letting the edit through matches what we intended with this PR. We should be consistent and either block both cases or allow both, and I think we already settled on allowing it here:

Copy link
Copy Markdown
Contributor

We only restrict moving forward, not historically.

@Gonals
Gonals self-requested a review September 8, 2026 13:33

@marufsharifi marufsharifi 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.

LGTM

@marufsharifi

Copy link
Copy Markdown
Contributor

@Gonals, could you please merge this when you get a chance, since everyone has approved it? Thanks!

@Gonals
Gonals merged commit b63843b into Expensify:main Sep 10, 2026
34 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@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/Gonals in version: 9.4.76-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

Yes — help site changes are required. Draft PR: #100905

This PR removed the creation guard when editing an existing manual or odometer distance expense, so members can now change the distance on expenses they created before the workspace started requiring map or GPS distance. Neither that rule nor this new exception was documented anywhere under docs/articles — the Require GPS or map entry setting had no help site coverage at all.

What I changed

File Update
docs/articles/new-expensify/workspaces/Set-distance-rates.md New admin sections on enabling Require GPS or map entry and what happens to existing manual/odometer expenses, plus 2 FAQ entries
docs/articles/new-expensify/reports-and-expenses/Distance-Expenses.md Notes on the Manual and Odometer creation steps, a paragraph in the edit section covering this PR's behavior, plus 2 FAQ entries

One thing to flag: I deliberately left commuter exclusions out of the public docs. The Exclude commutes row is gated behind the commuterExclusions beta in PolicyDistanceRatesSettingsPage.tsx:106 — a test account without the beta never sees it, so documenting it now would describe a feature most users can't reach. The articles cover the generally available Require GPS or map entry path instead, and the locked-toggle FAQ is worded generically so it stays correct. Worth a follow-up docs PR once the beta goes GA.

UI label verification

Checked live against dev NewDot on web:

  • Workspaces > [workspace] > Distance rates — page title Distance rates, settings entry point is a Settings button
  • Toggle label is exactly Require GPS or map entry with subtitle "Manual and odometer entry will be disabled."

Not screen-confirmed (beta-gated or modal-only), sourced from src/languages/en.ts:

  • The blocking modal: title "Require GPS or map entry", body "This workspace requires either map-based or GPS-tracked distance expenses.", button Got it
  • All Exclude commutes strings — which is why none of them made it into the articles

@fedirjh, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

@IuliiaHerets

Copy link
Copy Markdown

Hi @fedirjh. We are not seeing the “Exclude a fixed distance per claim” feature in the workspace’s Distance Settings.
Is this the same as the “Exclude usual commute” feature?

bandicam.2026-09-11.03-43-26-483.mp4

cc @JmillsExpensify @Gonals @mjasikowski @marufsharifi

@fedirjh
fedirjh deleted the fix/98223-edit-existing-distance branch September 11, 2026 09:18
@fedirjh

fedirjh commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@IuliiaHerets Yes, the copy was updated recently.

@IuliiaHerets

Copy link
Copy Markdown

@fedirjh can you please change the QA steps then?
And here as well

@fedirjh

fedirjh commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

@IuliiaHerets Updated

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.76-1 🚀

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