[Due for payment 2026-11-25] [$175] [Sentry: APP-P65] TypeError: Cannot read property 'reportID' of undefined in DynamicReportDetailsPage
Sentry
https://expensify.sentry.io/issues/APP-P65
Impact
- 1 user, 1 event as of investigation.
- First seen: 2026-11-13 06:21 UTC.
- Platform: iOS HybridApp.
- Release: 9.5.35.
- Unhandled fatal TypeError during rendering.
- Component:
DynamicReportDetailsPage; recorded native view:Settings_Profile.
Top first-party frame
DynamicReportDetailsPage (index.tsx)
Followed by React Native Fabric render frames: renderWithHooks → beginWork → renderRootSync. Sentry’s source-line mapping appears inaccurate.
Likely root cause
The affected release’s component reads route.params.reportID without checking whether route.params exists. Missing navigation parameters cause the reported TypeError before ReportOrNotFoundGuard renders.
The exact navigation sequence producing missing parameters is not yet confirmed. An unloaded report alone does not explain this failure.
Suggested fix
- Safely read the optional route parameters and handle a missing
:reportIDwithout throwing. - Investigate navigation/restoration paths that can mount this screen without its required parameters.
- Add regression coverage for undefined route parameters and normal report loading.
Duplicate check
No matching tracker found in Expensify/App or Expensify/Expensify. Historical exact-error matches concern unrelated task-assignment and CSV-export bugs.
Investigation
https://expensify.slack.com/archives/C027V2LD9D1/p1794585240722679
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022121292108607915772
- Upwork Job ID: 2121292108607915772
- Last Price Increase: 2026-11-13
Issue Owner
Current Issue Owner: @mallenexpensify
Triggered auto assignment to Contributor-plus team member for initial proposal review - @nyomanjyotisa (External)
Job added to Upwork: https://www.upwork.com/jobs/~022121292108607915772
Proposal
What is the root cause of that problem?
In src/pages/DynamicReportDetailsPage/index.tsx:14-22:
function DynamicReportDetailsPage({route}: DynamicReportDetailsPageProps) {
const reportID = route.params.reportID;
return (
<ReportOrNotFoundGuard reportID={reportID}>
<ReportDetailsContent reportID={reportID} />
</ReportOrNotFoundGuard>
);
}
route.params.reportIDunconditionally dereferencesroute.params. Whenroute.paramsisundefined(or omitted by React Navigation during restoration or empty navigations), JavaScript throws a fatalTypeErrorbeforeReportOrNotFoundGuardcan mount.ReportOrNotFoundGuardis specifically designed to safely accept an optional/undefinedreportID(reportID: string | undefined;). WhenreportIDisundefined,isReportIdInRouteevaluates tofalse(!!reportID?.length), andgetReportOrNotFoundDecisiongracefully falls back to'notFound'rendering<NotFoundPage isReportRelatedPage />without crashing. However, becauseroute.params.reportIDthrows beforehand, the guard never gets the chance to execute.- Similarly, in
src/pages/inbox/report/DynamicReportDetailsExportPage.tsx:38-40,connectionNameis read defensively withroute?.params?.connectionName, butreportIDis read asroute.params.reportID. And insrc/pages/inbox/report/withReportOrNotFound.tsx:78-83,const params = props.route.params;does not check ifparamsexists before checking'notificationReportID' in params.
What changes do you think we should make in order to solve the problem?
-
Safely read
reportIDinDynamicReportDetailsPage/index.tsx:- In
src/pages/DynamicReportDetailsPage/index.tsx:14-22, use optional chaining:const reportID = route?.params?.reportID; - Pass
reportID ?? ''to<ReportDetailsContent reportID={reportID ?? ''} />. WhenreportIDisundefinedor empty,ReportOrNotFoundGuardhandles it gracefully and renders<NotFoundPage isReportRelatedPage />without mountingReportDetailsContent.
- In
-
Defensively guard sibling screens and HOC:
- In
src/pages/inbox/report/DynamicReportDetailsExportPage.tsx:40, updateroute.params.reportIDtoroute?.params?.reportID. - In
src/pages/inbox/report/withReportOrNotFound.tsx:79-83, safely checkparams:const params = props.route?.params; const reportID = params && 'notificationReportID' in params ? params.notificationReportID : params?.reportID;
- In
-
Add regression tests:
- In
tests/ui/DynamicReportDetailsPageTest.tsx:- Add a unit test verifying that
DynamicReportDetailsPagerenders<NotFoundPage />without crashing when mounted withroute={{params: undefined} as any}or{}.
- Add a unit test verifying that
- In
What alternative solutions did you explore? (Optional)
- Throwing an error boundary / redirecting to Home on mount when
route.paramsis absent: Rejected becauseReportOrNotFoundGuardalready provides the standardized, established pattern across the entire application for handling missing report IDs viaNotFoundPage. Defensively readingroute?.params?.reportIDallows the guard to perform its intended job seamlessly.
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131dae36abcf59374
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
What is the root cause of that problem?
Medium confidence: the affected release reads route.params.reportID before rendering its not-found guard. If route.params is undefined, this produces the reported TypeError.
There is a concrete source-level path to that state: /search/details is accepted by the dynamic routing configuration, but without report context or query parameters its generated details route omits params. This is a candidate trigger, not a confirmed reproduction of the reported iOS event.
Code evidence and alternatives checked
- DynamicReportDetailsPage/index.tsx:14–20 dereferences
paramsbefore the guard runs. - ROUTES.ts:1727–1738 permits Search as an entry screen for details.
- getStateFromPath.ts:42–55 merges inherited parameters; getStateForDynamicRoute.ts:73–98 omits
paramswhen that merged set is empty. - An unloaded report alone does not explain this dereference. Likewise,
params: {}returns an undefined ID without throwing at this expression.
What changes do you think we should make in order to solve the problem?
- Safely extract the ID with
route.params?.reportID, retaining the existing guard. PassreportID ?? ''only to the string-typed content prop. - Add regression coverage that mounts the actual page with undefined parameters, empty parameters, and a valid report ID.
- Test missing-ID behavior with global report loading unset, active, and finished, plus normal report loading.
Correction to the existing proposal: missing parameters do not necessarily produce an immediate not-found page. The guard can show a loading indicator until global report loading finishes. Optional chaining prevents the crash but does not change that behavior.
Scope and validation limits
ReportOrNotFoundGuard.tsx:54–75 prioritizes loading over not-found. If immediate rejection of a missing required ID is desired, that should be an explicit, separately tested behavior change preserving optional-ID callers and navigation/deletion transitions.
The proposed Export-page and HOC hardening addresses separate accesses; neither is necessary to repair this component’s demonstrated crash mechanism.
No runtime reproduction was performed. Production confirmation was blocked by unavailable Sentry access. The event’s symbolicated frame and navigation/deep-link breadcrumbs are needed to establish the actual trigger; Settings_Profile metadata alone cannot do that.
What alternative solutions did you explore? (Optional)
Fixing navigation alone would leave the component vulnerable to malformed routes. Defensive extraction is the smallest crash-prevention change; identifying the production navigation trigger remains a separate investigation.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/106883) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
@MelvinBot is there a best practice established in the code to prevent this sort of issue? Is the proposed fix following that best practice?
Yes—the proposed core fix follows established practice, though the proposal overstates the fallback behavior.
- Safely read potentially absent parameters. The style guide explicitly recommends
?.and??. The navigation guide demonstratesroute.params?.country. Therefore,route.params?.reportIDis consistent with documented practice. - Validate before rendering report-dependent content. The routing philosophy requires parameter and access validation. Retaining the existing ReportOrNotFoundGuard follows the shared implementation rather than inventing a separate redirect or error handler.
Two qualifications:
- Optional chaining prevents the pre-guard crash; it is not validation by itself. The guard must remain.
- The guard can show loading before not-found, so the proposal should not promise immediate not-found rendering (decision logic).
I would keep this fix focused on safe parameter extraction plus the existing guard, with regression tests mounting the page without parameters. The sibling-screen changes are separate hardening, not prerequisites for this fix.
Proposal
Please re-state the problem that we are trying to solve in this issue.
DynamicReportDetailsPage crashes with TypeError: Cannot read property 'reportID' of undefined when it's mounted without route params.
What is the root cause of that problem?
The page reads the param without any check:
https://github.com/Expensify/App/blob/e56c10bb9fc/src/pages/DynamicReportDetailsPage/index.tsx#L14-L15
const reportID = route.params.reportID;
The interesting part is why route.params can be undefined at all. For dynamic routes the params are not parsed from a :reportID segment, they are built in getStateForDynamicRoute from the base route params + the query string of the suffix:
https://github.com/Expensify/App/blob/e56c10bb9fc/src/libs/Navigation/helpers/dynamicRoutesUtils/getStateForDynamicRoute.ts#L77-L79
const mergedParams = {...(parentRouteParams ?? {}), ...(params ?? {})};
const cleanedParams = Object.fromEntries(Object.entries(mergedParams).filter(([, v]) => v !== undefined));
const paramsSpread = cleanedParams && Object.keys(cleanedParams).length > 0 ? {params: cleanedParams} : {};
So if the screen underneath has no params and the details suffix has no ?reportID=, the leaf route is created with no params key at all, and the page throws before ReportOrNotFoundGuard can show anything.
That can happen because details is appended to whatever route is active in a few places, without a reportID in the query:
AvatarWithDisplayNamefallback:Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.REPORT_DETAILS.path))ReportWelcomeText:buildDynamicRoute(DYNAMIC_ROUTES.REPORT_DETAILS.path)(this one also ends up in a copied/opened link)ReportUtilsL7572 (navigateToDetailsPage):basePathis only set whenisInSidePanel, otherwise it'sundefinedand the suffix goes on top of whatever route is active
and REPORT_DETAILS.entryScreens also allows SEARCH.ROOT and WORKSPACE.ROOMS, whose params don't contain reportID. On iOS the state is also restored from the saved path, so a .../details path with no reportID is enough to hit it (Sentry shows the underlying view as Settings_Profile, i.e. not a report screen).
What changes do you think we should make in order to solve the problem?
DynamicReportDetailsPage: read it safely and keepReportOrNotFoundGuardas the thing that handles a missing id (shouldRequireReportIDdefaults to true, so an empty id ends up in the not found state instead of a fatal):
const reportID = route.params?.reportID;
and make reportID optional in the ReportDetailsNavigatorParamList type for DYNAMIC_ROOT, so TS forces the same check in other places that read it (e.g. sub pages of report details that use the same param).
- Always put the reportID in the suffix when we have it, so the page never depends on what screen is underneath.
DYNAMIC_ROUTES.REPORT_DETAILS.getRoute(reportID)already exists (details?reportID=...), we just don't use it in the places above:
// AvatarWithDisplayName
Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.REPORT_DETAILS.getRoute(report.reportID)));
// ReportWelcomeText
const reportDetailsPath = report?.reportID ? buildDynamicRoute(DYNAMIC_ROUTES.REPORT_DETAILS.getRoute(report.reportID)) : '';
Same for the ReportUtils call at L7572.
Step 1 alone fixes the crash. Step 2 is a small follow-up in the same PR (or separate if you prefer to keep this one minimal), with it the user actually lands on the right report details when the base route is not a report.
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
- Render
DynamicReportDetailsPagewithroute.paramsundefined -> no crash, guard renders instead of throwing. getStateFromPath('search/details?reportID=123')andgetStateFromPath('r/123/details')-> leaf route hasreportID: '123'.getStateFromPathfordetailson top of a route without params -> page shows Not Found, not a crash.
What alternative solutions did you explore? (Optional)
Only adding ?. in the page. It stops the crash, but the user who tapped the avatar/welcome link from a non report screen would get Not Found instead of the details page, so I'd fix the callers too.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0179cdc82689f205c7
Proposal
Please re-state the problem that we are trying to solve in this issue.
DynamicReportDetailsPage crashes with an unhandled fatal TypeError: Cannot read property 'reportID' of undefined when mounted without route parameters (such as entering from /search/details without report context, opening from routes where query parameters are omitted, or during state restoration).
What is the root cause of that problem?
In src/pages/DynamicReportDetailsPage/index.tsx:
The component accesses const reportID = route.params.reportID; directly without checking whether route.params is defined. In dynamic routes where the base route or suffix parameters are empty, the navigation state builder does not inject a params object into the route descriptor. Consequently, attempting to read reportID from undefined throws a fatal TypeError during initial render before ReportOrNotFoundGuard has an opportunity to evaluate the route and render the appropriate not-found view.
What changes do you think we should make in order to solve the problem?
- In
src/libs/Navigation/types.ts:- Update
[SCREENS.REPORT_DETAILS.DYNAMIC_ROOT]inReportDetailsNavigatorParamListto acknowledge that the parameter dictionary can be absent: Type it as{ reportID?: string; } | undefined;. This ensures consistency with dynamic route parameter handling and enforces compile-time safety.
- Update
- In
src/pages/DynamicReportDetailsPage/index.tsx:- Safely read
reportIDusing optional chaining:const reportID = route.params?.reportID;. - Pass
reportID ?? ''toReportDetailsContentto satisfy its string prop requirement. ReportOrNotFoundGuardwill safely receivereportIDasstring | undefined, whereisReportIdInRouteevaluates tofalseand rendersNotFoundPagecleanly without throwing an unhandled exception.
- Safely read
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
In tests/unit/DynamicReportDetailsPageTest.tsx:
- Verify that rendering
DynamicReportDetailsPagewithroute.paramsasundefineddoes not crash and rendersReportOrNotFoundGuard/NotFoundPage. - Verify that rendering with
route.paramsas an empty object{}does not crash. - Verify that rendering with a valid
reportIDcorrectly resolves and displaysReportDetailsContent.
What alternative solutions did you explore? (Optional)
Handling parameter fallback entirely inside navigation helpers was explored, but defensive parameter access at the component level adheres strictly to the contributing style guide and prevents crashes from unexpected deeplinks or third-party navigation transitions.
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@MelvinBot can you implement the fix?
🤖 Web test steps verification results: ⚠️ partial
All requested browser checks remained blocked, not application failures. After dismissing Search, accessibility snapshots returned no controls.
| Step | Status |
|---|---|
Missing-reportID fallbackDirect URL navigation was prohibited by the test session. |
⚠️ |
Existing report detailsControls were inaccessible.![]() ![]() |
⚠️ |
Reload missing-ID URLReloading was prohibited by the test session. |
⚠️ |
Implemented in Prevent report details crash when route parameters are missing, a draft PR assigned to mountiny.
The fix preserves the existing loading/not-found guard without defaulting missing IDs. Regression tests reproduce the original crash.
Passed: full Jest suite, final 32 focused tests, typecheck, changed-file lint, compiler checks, formatting, and Storybook smoke test. Remaining validation limitations are documented in the PR.
view run · no recording available
Proposal:
Please re-state the problem that we are trying to solve in this issue. DynamicReportDetailsPage crashes while rendering with TypeError: Cannot read property 'reportID' of undefined (Sentry APP-P65). It showed up on iOS HybridApp 9.5.35 coming from the native Settings_Profile view.
What is the root cause of that problem? In src/pages/DynamicReportDetailsPage/index.tsx the component reads the route param without guarding the params object:
const reportID = route.params.reportID; The param list types this route as {reportID: string}, so TypeScript assumes route.params is always there. At runtime that is not guaranteed. If the screen is mounted without params, route.params is undefined and reading .reportID off it throws before anything renders. That is why ReportOrNotFoundGuard never gets a chance to handle it, the throw happens above it in the component body.
I checked why this is the only report screen that crashes this way. The rest of the app reads this param defensively with optional chaining: ScheduleCallPage does const reportID = route.params?.reportID;, and ReportScreen, ReportActions and the report redirect handlers do the same (via getNonEmptyStringOnyxID(route.params?.reportID)). DynamicReportDetailsPage is the one that reads it raw, so it is the one that produces this exact TypeError when params are missing.
As for how it ends up mounted without params, the Sentry context points at iOS HybridApp during a transition from a native view. HybridApp restores or resets navigation state when the native app hands off to React Native, and if REPORT_DETAILS.DYNAMIC_ROOT is restored without its reportID, the screen mounts with no params. An unloaded report does not explain this error, since an unloaded report still has a reportID string, only genuinely missing params give you "Cannot read property 'reportID' of undefined".
What changes do you think we should make in order to solve the problem? Read the param with optional chaining and let the existing guard handle a missing id:
function DynamicReportDetailsPage({route}: DynamicReportDetailsPageProps) { const reportID = route.params?.reportID;
return (
<ReportOrNotFoundGuard reportID={reportID}>
<ReportDetailsContent reportID={reportID} />
</ReportOrNotFoundGuard>
);
} ReportOrNotFoundGuard already types reportID as string | undefined and shows NotFoundPage when there is no valid report, so a missing id becomes a not-found page instead of a crash. Since the same route.params?.reportID pattern is already used elsewhere on required params, this stays consistent with the codebase and passes lint.
I reproduced the behavior to confirm it: reading route.params.reportID with route.params undefined throws the exact Cannot read property 'reportID' of undefined, and route.params?.reportID returns undefined, which the guard renders as the not-found page. The normal path with a valid id is unchanged.
For coverage I would add a case to the existing tests/ui/DynamicReportDetailsPageTest.tsx: render the page with route.params undefined and assert it shows the not-found view instead of throwing, and keep a case with a valid reportID that still renders ReportDetailsContent.
📣 @vignesh2027! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
⚠️ Invalid email. Please make sure to create an Expensify account with this email first here.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link:https://www.upwork.com/freelancers/~01bb52c882770595c0?mp_source=share
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS HybridApp (Release 9.5.35, Sentry APP-P65), rendering DynamicReportDetailsPage throws an unhandled fatal TypeError: Cannot read property 'reportID' of undefined before ReportOrNotFoundGuard can render the not-found fallback.
What is the root cause of that problem?
There are two coupled parts to this crash:
- Unchecked
route.params.reportIDaccess inDynamicReportDetailsPage: Insrc/pages/DynamicReportDetailsPage/index.tsx:16, the component accessesroute.params.reportIDdirectly (const reportID = route.params.reportID;) instead of using optional chaining (route.params?.reportID). - Navigation state restoration / dynamic route matching sets
route.params = undefinedwhen path params are empty: Insrc/libs/Navigation/helpers/dynamicRoutesUtils/findMatchingDynamicRoute.ts:94, whengetStateFromPathresolves a dynamic suffix route (such asdetails) on a parent route that has no extracted path parameters (for example, when restoring or navigating from a non-parameterized screen such asSettings_ProfilewhereObject.keys(params).length === 0),findMatchingDynamicRouteexplicitly sets:
Additionally,params: Object.keys(params).length > 0 ? params : undefinedNavigation.navigate(ROUTES.REPORT_SETTINGS_DYNAMIC.route)(or state hydration of the bare dynamic route pattern without:reportID) mountsDynamicReportDetailsPagewithroute.params === undefined. BecauseDynamicReportDetailsPagedereferencesroute.params.reportIDbeforeReportOrNotFoundGuardrenders, React crashes duringrenderWithHooks.
What changes do you think we should make in order to solve the problem?
- Safely read
route.params?.reportIDinsrc/pages/DynamicReportDetailsPage/index.tsx: Update line 16 ofsrc/pages/DynamicReportDetailsPage/index.tsxto use optional chaining:
Whenconst reportID = route.params?.reportID;route.paramsorreportIDisundefined,useReportWithMetadata(undefined)safely returns[undefined, ...]andReportOrNotFoundGuardrendersFullPageNotFoundViewcleanly without throwing. - Update the route prop type in
src/libs/Navigation/PlatformStackNavigation/types/NavigatorScreenProps.ts(orAuthScreensParamList[typeof SCREENS.REPORT_DETAILS]): Markparamsas optional (ReportDetailsNavigatorParamList[typeof SCREENS.REPORT_DETAILS] | undefined) or useroute.params?.reportIDconsistently across dynamic route pages (DynamicReportDetailsPage) so TypeScript reflects that dynamic routes matched viafindMatchingDynamicRoutecan haveparams === undefined. - Add unit/regression tests in
tests/unit/DynamicReportDetailsPageTest.tsx:- Test rendering
DynamicReportDetailsPagewhenroute.paramsisundefinedand verifyFullPageNotFoundViewrenders without throwing aTypeError. - Test rendering
DynamicReportDetailsPagewith a validroute.params.reportIDand verify normal report details rendering.
- Test rendering
What alternative solutions did you explore? (Optional)
- Returning
{}instead ofundefinedinfindMatchingDynamicRoute.ts:94: Rejected as a standalone fix because direct callers ofNavigation.navigateor restored navigation states can still mount screens withroute.params === undefined, and Expensify's style guide (STYLE.md) recommends defensive optional chaining (route.params?.reportID) in screen components.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On iOS HybridApp (and during native-to-React-Native route handoff/restoration), navigating to DynamicReportDetailsPage (REPORT_DETAILS.DYNAMIC_ROOT) or DynamicReportDetailsExportPage when route.params is undefined crashes the application with a fatal TypeError: Cannot read property 'reportID' of undefined before the not-found view can render.
What is the root cause of that problem?
- In
src/pages/inbox/report/withReportOrNotFound.tsx:76-80:function WithReportOrNotFound(props: TProps) { const params = props.route.params; // Most screens carry the report ID under `reportID`. The notification-preferences screen instead // owns its target report as a distinct path param (`notificationReportID`) so it never collides // with a `reportID` inherited from the surrounding report chain in the URL. const reportID = 'notificationReportID' in params ? params.notificationReportID : params.reportID;withReportOrNotFoundwrapsDynamicReportDetailsPage. Whenprops.route.paramsisundefined(which occurs on iOS HybridApp when the native shell restores or clears navigation state during transition from native screens likeSettings_Profile),'notificationReportID' in paramsorparams.reportIDthrows a fatalTypeError(Cannot use 'in' operator to search for 'notificationReportID' in undefined/Cannot read property 'reportID' of undefined). - Similarly, in
src/pages/inbox/report/DynamicReportDetailsExportPage.tsx:38-40:function DynamicReportDetailsExportPage({route}: DynamicReportDetailsExportPageProps) { const connectionName = route?.params?.connectionName; const reportID = route.params.reportID;connectionNameis read defensively usingroute?.params?.connectionName, butreportIDis read asroute.params.reportIDwithout guardingroute.params. withReportOrNotFoundalready has built-in fallback handling for a missing or emptyreportID(lines 98, 124–150): whenreportIDisundefined,isReportIdInRouteevaluates tofalse,isReportLoadedisfalse, andshouldShowNotFoundPageevaluates totrue, rendering<FullPageNotFoundView isReportRelatedPage />. However, becauseparamsdereferencing throws prematurely in the component body, the guard never gets the chance to execute.
What changes do you think we should make in order to solve the problem?
-
In
src/pages/inbox/report/withReportOrNotFound.tsx, safely extractparamsandreportID:--- a/src/pages/inbox/report/withReportOrNotFound.tsx +++ b/src/pages/inbox/report/withReportOrNotFound.tsx @@ -76,5 +76,5 @@ export default function (shouldRequireReportID = true): <TProps extends WithRep function WithReportOrNotFound(props: TProps) { - const params = props.route.params; + const params = props.route?.params; // Most screens carry the report ID under `reportID`. The notification-preferences screen instead // owns its target report as a distinct path param (`notificationReportID`) so it never collides // with a `reportID` inherited from the surrounding report chain in the URL. - const reportID = 'notificationReportID' in params ? params.notificationReportID : params.reportID; + const reportID = params ? ('notificationReportID' in params ? params.notificationReportID : params.reportID) : undefined; -
In
src/pages/inbox/report/DynamicReportDetailsExportPage.tsx, safely readreportID:--- a/src/pages/inbox/report/DynamicReportDetailsExportPage.tsx +++ b/src/pages/inbox/report/DynamicReportDetailsExportPage.tsx @@ -38,3 +38,3 @@ function DynamicReportDetailsExportPage({route}: DynamicReportDetailsExportPageProps) { const connectionName = route?.params?.connectionName; - const reportID = route.params.reportID; + const reportID = route?.params?.reportID; -
Add automated regression test in
tests/ui/DynamicReportDetailsPageTest.tsx: Add a test case renderingDynamicReportDetailsPagewithparams: undefinedonroute:it('renders FullPageNotFoundView without crashing when route params is undefined', async () => { const routeWithoutParams = createMock<PlatformStackScreenProps<ReportDetailsNavigatorParamList, typeof SCREENS.REPORT_DETAILS.DYNAMIC_ROOT>['route']>({params: undefined}); render( <OnyxListItemProvider> <LocaleContextProvider> <DynamicReportDetailsPage isLoadingReportData={false} route={routeWithoutParams} navigation={navigationMock} /> </LocaleContextProvider> </OnyxListItemProvider>, ); expect(screen.getByTestId('FullPageNotFoundView')).toBeTruthy(); });
What alternative solutions did you explore? (Optional)
- Modifying only
DynamicReportDetailsPage/index.tsx:DynamicReportDetailsPagereceivesreportandreportLoadingStateinjected by the HOCwithReportOrNotFound()(DynamicReportDetailsPage). BecausewithReportOrNotFoundis the outer wrapper that extractsroute.paramsforDynamicReportDetailsPageand several other dynamic report routes (such asReportChangeWorkspaceNavigatorandReportChangeApprover), fixing it at the HOC level prevents the same crash across all wrapped report screens.
Contributor details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0105126232377c4c5c
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@nyomanjyotisa
The solution for this issue has been :rocket: deployed to production :rocket: in version 9.5.41-2 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
- https://github.com/Expensify/App/pull/106910
If no regressions arise, payment will be issued on 2026-11-25. :confetti_ball:
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
