From 86dbd91ec72721b199613dec521be03123a2176f Mon Sep 17 00:00:00 2001 From: Pavel Piuro Date: Mon, 29 Dec 2025 16:54:35 +0400 Subject: [PATCH] Fix DISTANCE_REQUEST_CREATE route trailing slash causing NotFound 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 #77760 --- src/ROUTES.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 4ffe479ff684..a68bd7508dc5 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1268,8 +1268,12 @@ const ROUTES = { }, DISTANCE_REQUEST_CREATE: { route: ':action/:iouType/start/:transactionID/:reportID/distance-new/:backToReport?', - getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backToReport?: string) => - `${action as string}/${iouType as string}/start/${transactionID}/${reportID}/distance-new/${backToReport ?? ''}` as const, + getRoute: (action: IOUAction, iouType: IOUType, transactionID: string, reportID: string, backToReport?: string) => { + if (backToReport) { + return `${action as string}/${iouType as string}/start/${transactionID}/${reportID}/distance-new/${backToReport}` as const; + } + return `${action as string}/${iouType as string}/start/${transactionID}/${reportID}/distance-new` as const; + }, }, DISTANCE_REQUEST_CREATE_TAB_MAP: { route: 'distance-map',