Skip to content

Conversation

@eL1fe
Copy link

@eL1fe eL1fe commented Dec 29, 2025

Summary

Fixes #77760

The DISTANCE_REQUEST_CREATE.getRoute() function was generating a URL with a trailing slash when backToReport parameter is undefined/empty. This caused the route to not match the expected pattern, resulting in a NotFound page when navigating to the "Track distance" screen.

Before:

create/track-expense/start/123/456/distance-new/

After:

create/track-expense/start/123/456/distance-new

Root Cause

In src/ROUTES.ts, the getRoute function used template literals that always included the trailing segment:

return `${action}/${iouType}/start/${transactionID}/${reportID}/distance-new/${backToReport}` as const;

When backToReport is undefined, this produced a trailing slash.

Fix

Added a conditional check to only append backToReport when it has a value:

if (backToReport) {
    return `${action}/${iouType}/start/${transactionID}/${reportID}/distance-new/${backToReport}` as const;
}
return `${action}/${iouType}/start/${transactionID}/${reportID}/distance-new` as const;

Test Plan

  1. Open a chat
  2. Click "+" → "Track distance"
  3. Verify the screen loads correctly without NotFound error
  4. Verify the URL does not have a trailing slash

Tests

  • Verify that no errors appear in the JS console
  • I verified there are no console errors (after closing the498 issue, those are separate)

QA Steps

  • I linked the correct issue in the Fixes line above

When `backToReport` is undefined, the current implementation generates
a route with a trailing slash after `distance-new/` which doesn't match
the route pattern and causes the NotFound page to appear.

Changed to use the same pattern as MONEY_REQUEST_CREATE which
conditionally adds the backToReport segment only when it exists.

Fixes Expensify#77760
@eL1fe eL1fe requested review from a team as code owners December 29, 2025 12:56
@melvin-bot melvin-bot bot requested review from JmillsExpensify, flaviadefaria, heyjennahay, joekaufmanexpensify and trjExpensify and removed request for a team December 29, 2025 12:56
@github-actions
Copy link
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@melvin-bot melvin-bot bot requested review from Valforte and removed request for a team December 29, 2025 12:56
@melvin-bot
Copy link

melvin-bot bot commented Dec 29, 2025

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

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.

[$250] Full story: Clicking on Add expense > Track distance /Create expense leads to NotFound

1 participant