You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$250] “Page not found” error when submitting manual distance entry offline #74640
Version Number: v9.2.47-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#74511 Email or phone of affected tester (no customers):applausetester+dp31fsdjfgj@applause.expensifail.com Issue reported by: Applause Internal Team Device used: Mac / Safari App Component: Other
Action Performed:
Create a workspace
Go offline
Delete the workspace
Click FAB → Track distance → Manual
Enter any value and submit
Expected Result:
“Choose recipient” page should be displayed after submitting.
Actual Result:
Error message appears: “Hmm… it’s not here” “Oops, this page cannot be found”
The page is partially visible and appears semi-transparent (opaque).
What changes do you think we should make in order to solve the problem?
We should not allow navigate to confirmation page if defaultExpensePolicy has pending action is delete (or we can use utils function isPolicyAccessible). It will navigate the user to Choose recipient steps
What alternative solutions did you explore? (Optional)
We should filter out the expense policy if it has pending action is delete
if (isPaidGroupPolicy(activePolicy) && activePolicy?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE) {
return activePolicy;
}
// If there is exactly one group policy, use that as the default expense policy
const groupPolicies = Object.values(allPolicies ?? {}).filter((policy) => isPaidGroupPolicy(policy) && policy?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);
if (groupPolicies.length === 1) {
return groupPolicies.at(0);
}
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
Please re-state the problem that we are trying to solve in this issue.
When a user deletes a workspace while offline and then chooses “Track distance → Manual”, the flow should continue to the “Choose recipient” step. Instead, the form redirects to a semi-transparent “Hmm… it’s not here” not-found view.
What is the root cause of that problem?
The helper that decides which workspace should be used for new expenses (useDefaultExpensePolicy) never checks whether the workspace is in the middle of being deleted. After deleting a workspace while offline, Onyx still contains the workspace record with pendingAction: DELETE. Because the hook keeps returning that record, every new distance expense tries to load a workspace the server will soon remove, and AccessOrNotFoundWrapper sends the user to the error page.
What changes do you think we should make in order to solve the problem?
Add a guard inside useDefaultExpensePolicy that filters out any policy whose pendingAction is DELETE. If the active policy fails the guard, fall back to the first non-deleted paid policy. This keeps the tracker pointed at a valid workspace and lets the flow reach the participant selector again.
Please re-state the problem that we are trying to solve in this issue.
“Page not found” error when submitting manual distance entry offline when the default workspace is also deleted offline.
What is the root cause of that problem?
In the useDefaultExpensePolicy hook, we do not check if the policy is accessible or not. When that policy is pending deletion or no longer accessible (leave), the flow navigates into screens that require a writable/accessiblereport/policy, which shows NotFound.
Directly checking only pendingAction !== DELETE misses several cases: empty policy, missing id, user not a member, policy errors. This leads to the flow still showing the unaccessible policy on the participants page.
If we only check for pendingAction !== DELETE, the participants step still shows the policy that the user has left , enabling track submissions against inaccessible workspaces.
Leaving a workspace did not optimistically archive its reports on the frontend, so they remained visible in offline mode.
What changes do you think we should make in order to solve the problem?
We should use isPolicyAccessible instead of only checking pendingAction because directly checking for pending actions misses some cases like when user leaves the policy.
We should also align leave workspace action with delete workspace:
Optimistically archive the related reports and add a CLOSED action (reason: REMOVED_FROM_POLICY) so they no longer appear accessible on the frontend after leaving workspace in offline mode. This aligns with the delete behavior and avoids picking them during Participant selection.
Pseudocode
constpendingChatMembers=ReportUtils.getPendingChatMembers([sessionAccountID],[],CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE);constcurrentTime=DateUtils.getDBTime();constfinallyData: OnyxUpdate[]=[];workspaceChats.forEach((report)=>{constparentReport=ReportUtils.getRootParentReport({report});constreportToCheckOwner=isEmptyObject(parentReport) ? report : parentReport;if(ReportUtils.isPolicyExpenseChat(report)&&!ReportUtils.isReportOwner(reportToCheckOwner)){return;}optimisticData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.REPORT}${report?.reportID}`,value: {statusNum: CONST.REPORT.STATUS_NUM.CLOSED,stateNum: CONST.REPORT.STATE_NUM.APPROVED,oldPolicyName: policy?.name??'',isPinned: false,},},{onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID}`,value: {
pendingChatMembers,},},{onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`,value: {private_isArchived: currentTime,},},);// Add an optimistic closed action to mirror the server behavior and immediately hide the report from active viewsconstemailClosingReport=(report?.ownerAccountID&&report.ownerAccountID!==CONST.POLICY.OWNER_ACCOUNT_ID_FAKE)
? (allPersonalDetails?.[report.ownerAccountID]?.login??'')
: CONST.POLICY.OWNER_EMAIL_FAKE;constoptimisticClosedReportAction=ReportUtils.buildOptimisticClosedReportAction(emailClosingReport,policy?.name??'',CONST.REPORT.ARCHIVE_REASON.REMOVED_FROM_POLICY,);optimisticData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`,value: {[optimisticClosedReportAction.reportActionID]: optimisticClosedReportActionasReportAction,},});// Remove the optimistic closed action after server response to avoid duplicationfinallyData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`,value: {[optimisticClosedReportAction.reportActionID]: null,},});successData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID}`,value: {pendingChatMembers: null,},});failureData.push({onyxMethod: Onyx.METHOD.MERGE,key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${report?.reportID}`,value: {pendingChatMembers: null,},});});constparams: LeavePolicyParams={
policyID,email: sessionEmail,};API.write(WRITE_COMMANDS.LEAVE_POLICY,params,{optimisticData, successData, failureData, finallyData});
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
N/A
What alternative solutions did you explore? (Optional)
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: No PR appears to have introduced this bug directly.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Test 1
Precondition: Account should not have any workspaces
Create a workspace
Go offline
Delete the workspace
Click FAB → Track distance → Manual
Enter any value and submit
Verify “Choose recipient” page is displayed after submitting.
Test 2
Precondition: Account should not have any workspaces
[USER A] - Create a workspace Invite User B
[USER B] - Go offline after workspace appears on workspace list page
[USER B] - Leave the workspace
[USER B] - Click FAB → Track distance → Manual
[USER B] - Enter any value and submit
[USER B] - Verify “Choose recipient” page is displayed after submitting.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
Activity
melvin-bot commentedon Nov 8, 2025
Triggered auto assignment to @RachCHopkins (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.daledah commentedon Nov 8, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Error message appears: “Hmm… it’s not here” “Oops, this page cannot be found”
The page is partially visible and appears semi-transparent (opaque).
What is the root cause of that problem?
Even though the workspace has been deleted, we still allow navigation to the confirmation page here.
App/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx
Lines 258 to 266 in 2087489
What changes do you think we should make in order to solve the problem?
We should not allow navigate to confirmation page if
defaultExpensePolicyhas pending action is delete (or we can use utils functionisPolicyAccessible). It will navigate the user toChoose recipientstepsApp/src/pages/iou/request/step/IOURequestStepDistanceManual.tsx
Lines 240 to 245 in 2087489
What alternative solutions did you explore? (Optional)
We should filter out the expense policy if it has pending action is delete
App/src/hooks/useDefaultExpensePolicy.tsx
Lines 10 to 18 in 2087489
Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.
ShridharGoel commentedon Nov 8, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user deletes a workspace while offline and then chooses “Track distance → Manual”, the flow should continue to the “Choose recipient” step. Instead, the form redirects to a semi-transparent “Hmm… it’s not here” not-found view.
What is the root cause of that problem?
The helper that decides which workspace should be used for new expenses (
useDefaultExpensePolicy) never checks whether the workspace is in the middle of being deleted. After deleting a workspace while offline, Onyx still contains the workspace record withpendingAction: DELETE. Because the hook keeps returning that record, every new distance expense tries to load a workspace the server will soon remove, andAccessOrNotFoundWrappersends the user to the error page.App/src/hooks/useDefaultExpensePolicy.tsx
Lines 5 to 18 in b295b20
What changes do you think we should make in order to solve the problem?
Add a guard inside
useDefaultExpensePolicythat filters out any policy whosependingActionisDELETE. If the active policy fails the guard, fall back to the first non-deleted paid policy. This keeps the tracker pointed at a valid workspace and lets the flow reach the participant selector again.Krishna2323 commentedon Nov 8, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
“Page not found” error when submitting manual distance entry offline when the default workspace is also deleted offline.
What is the root cause of that problem?
useDefaultExpensePolicyhook, we do not check if the policy is accessible or not. When that policy is pending deletion or no longer accessible (leave), the flow navigates into screens that require awritable/accessiblereport/policy, which showsNotFound.App/src/hooks/useDefaultExpensePolicy.tsx
Lines 10 to 20 in 2087489
pendingAction !== DELETEmisses several cases: empty policy, missingid, user not a member, policy errors. This leads to the flow still showing the unaccessible policy on the participants page.pendingAction !== DELETE, the participants step still shows the policy that the user has left , enabling track submissions against inaccessible workspaces.App/src/libs/actions/Policy/Policy.ts
Lines 1011 to 1014 in 2087489
What changes do you think we should make in order to solve the problem?
isPolicyAccessibleinstead of only checkingpendingActionbecause directly checking for pending actions misses some cases like when user leaves the policy.App/src/libs/PolicyUtils.ts
Lines 1409 to 1417 in 2087489
leave workspaceaction with delete workspace:REMOVED_FROM_POLICY) so they no longer appear accessible on the frontend after leaving workspace in offline mode. This aligns with the delete behavior and avoids picking them during Participant selection.Pseudocode
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
N/A
What alternative solutions did you explore? (Optional)
Result
RachCHopkins commentedon Nov 11, 2025
Easy repro
18 remaining items
brunovjk commentedon Nov 18, 2025
Great, reviewing ASAP
brunovjk commentedon Dec 2, 2025
Update: PR went into production yesterday, December 1st, according to this deployment checklist.
brunovjk commentedon Dec 8, 2025
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: No PR appears to have introduced this bug directly.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Test 1
Precondition: Account should not have any workspaces
Test 2
Precondition: Account should not have any workspaces
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-eb52-a01c-3185-6d21256fa954brunovjk commentedon Dec 8, 2025
@RachCHopkins when do you have some time to help with payment here? Thanks.
melvin-bot commentedon Dec 12, 2025
This issue has not been updated in over 15 days. @lakchote, @RachCHopkins, @Krishna2323, @brunovjk eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
RachCHopkins commentedon Dec 15, 2025
Payment Summary:
Upwork job here - now closed, and no contracts to end.
🟢 to request payment via NewDot.
brunovjk commentedon Dec 15, 2025
Requested in ND.
JmillsExpensify commentedon Dec 15, 2025
$250 approved for @brunovjk
Krishna2323 commentedon Dec 29, 2025
Requested in ND.
twisterdotcom commentedon Dec 30, 2025
@Krishna2323 has submitted payment for this report on ND here.
SO: https://stackoverflowteams.com/c/expensify/questions/7582
Zapier Logs
Run ID: 00040eee-1cd0-af97-b56f-46b38445c164