Fix onboarding null initial path crash#92646
Conversation
|
@cretadn22 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] |
|
@cretadn22 Sorry, I mistakenly marked the wrong PR as ready for review. This PR is not quite ready yet, but I will ping you when it is. Apologies for the confusion, and thanks! 😅 |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@cretadn22 PR is ready for review. The original production trigger depends on bad persisted onboarding/navigation state and is not reliably reachable through normal user actions. Also, setting the public Onyx key to For validation, I used the same controlled frontend probe on staging and dev:
Controlled proof script(() => {
const tag = '[Issue 92417]';
const proofId = 'issue-92417-proof';
document.getElementById(proofId)?.remove();
const showResult = ({title, detail, isCrash}) => {
const root = document.createElement('div');
root.id = proofId;
root.style.cssText = `
position: fixed;
inset: 0;
z-index: 2147483647;
display: flex;
align-items: center;
justify-content: center;
background: ${isCrash ? '#3b0505' : '#062d14'};
color: white;
font-family: Arial, sans-serif;
padding: 48px;
`;
const box = document.createElement('div');
box.style.cssText = `
width: min(1100px, 90vw);
border: 2px solid ${isCrash ? '#ff7a7a' : '#75d68b'};
border-radius: 10px;
padding: 32px;
`;
box.innerHTML = `
<h1 style="margin: 0 0 24px; font-size: 32px;">${title}</h1>
<pre style="white-space: pre-wrap; background: rgba(0,0,0,.35); padding: 20px; border-radius: 8px; font-size: 16px;">${detail}</pre>
<p style="opacity: .75;">Issue 92417 controlled frontend proof</p>
`;
root.appendChild(box);
document.body.appendChild(root);
};
const chunkKey = Object.keys(window).find((key) => key.startsWith('webpackChunk'));
if (!chunkKey) {
throw new Error(`${tag} Could not find webpack chunk registry.`);
}
let webpackRequire;
window[chunkKey].push([
[`issue-92417-proof-${Date.now()}`],
{},
(req) => {
webpackRequire = req;
},
]);
const candidates = Object.keys(webpackRequire.m).filter((id) => {
const source = Function.prototype.toString.call(webpackRequire.m[id]);
return source.includes('getOnboardingInitialPath') || (source.includes('onboardingInitialPath') && source.includes('getStateFromPath'));
});
console.log(tag, 'candidate modules:', candidates);
const params = {
isUserFromPublicDomain: false,
hasAccessiblePolicies: false,
onboardingValuesParam: undefined,
currentOnboardingPurposeSelected: 'newDotPersonalSpend',
currentOnboardingCompanySize: '11-50',
onboardingInitialPath: null,
onboardingValues: undefined,
isAccountValidated: true,
};
for (const id of candidates) {
const mod = webpackRequire(id);
for (const [exportName, exportedValue] of Object.entries(mod)) {
if (typeof exportedValue !== 'function') {
continue;
}
if (exportName !== 'getOnboardingInitialPath' && !Function.prototype.toString.call(exportedValue).includes('onboardingInitialPath')) {
continue;
}
console.log(tag, `Calling ${exportName} from module ${id} with onboardingInitialPath: null`);
try {
const result = exportedValue(params);
const detail = [
'NO CRASH',
'',
`Called module: ${id}`,
`Export: ${exportName}`,
'Input: onboardingInitialPath = null',
`Returned: ${result}`,
].join('\n');
console.log(tag, 'NO CRASH', detail);
showResult({
title: 'Fixed: onboarding null path no longer crashes',
detail,
isCrash: false,
});
return;
} catch (error) {
const detail = [
'CRASH REPRODUCED',
'',
`Called module: ${id}`,
`Export: ${exportName}`,
'Input: onboardingInitialPath = null',
'',
error?.stack || String(error),
].join('\n');
console.error(tag, error);
showResult({
title: 'Broken: onboarding null path crashes',
detail,
isCrash: true,
});
return;
}
}
}
throw new Error(`${tag} Could not find callable getOnboardingInitialPath export.`);
})();Screen.Recording.2026-06-04.at.4.26.02.PM.mp4 |
|
@cretadn22 Kind ping here. Thanks! |
|
@KJ21-ENG Could you update the test steps to follow the standard onboarding flow. This will allow QA to verify that the main user path is still working perfectly. Updated Test Steps:
|
@cretadn22 Done! |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-06-06.at.15.16.26.movAndroid: mWeb ChromeScreen.Recording.2026-06-06.at.15.13.05.moviOS: HybridAppScreen.Recording.2026-06-06.at.15.14.06.moviOS: mWeb SafariScreen.Recording.2026-06-06.at.15.11.20.movMacOS: Chrome / SafariScreen.Recording.2026-06-06.at.15.01.29.mov |
|
Due to a timeout issue, we need to kick off test job 8 again |
Explanation of Change
Normalize the saved onboarding initial path inside
getOnboardingInitialPath()before passing it to React Navigation or checking it with string helpers. WhenONYXKEYS.ONBOARDING_LAST_VISITED_PATHisnull, the helper now treats it as an empty path and falls back through the normal onboarding route logic instead of passingnullintogetStateFromPath().The PR also adds a regression unit test that covers the
nullpath case directly.Fixed Issues
$ #92417
PROPOSAL: #92417 (comment)
Tests
Offline tests
Same as tests. This change only normalizes the locally stored onboarding path before route parsing and does not add any network behavior.
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
N/A. This is a routing/helper crash prevention change covered by unit tests and does not change UI rendering.
Android: Native
N/A - no UI change.
Android: mWeb Chrome
N/A - no UI change.
iOS: Native
N/A - no UI change.
iOS: mWeb Safari
N/A - no UI change.
MacOS: Chrome / Safari
Screen.Recording.2026-06-04.at.4.26.02.PM.mp4