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
[Due for payment 2026-03-04] [$250] Expense - Distance expense created in offline is not shown in expense report #80591
Version Number: V9.3.9-1 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:#80003 Email or phone of affected tester (no customers):dreamnitethedragon+yydyd373@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Redminote 10S Android 13 App Component: Workspace Settings
Action Performed:
Launch app (use expensifail account)
Open expense report
Go offline
Tap add expense
Create a map distance expense offline
Note expense created is not in expense report
Navigate back to workspace chat
Note expense created in step 5 is created as new report
Expected Result:
Distance expense created in offline must be shown in expense report.
Actual Result:
Distance expense created in offline is not shown in expense report. Expense is shown in workspace chat as seperate new report.
Please re-state the problem that we are trying to solve in this issue.
When a user is inside an existing expense report and creates a distance expense while offline, the expense is incorrectly created as a new separate report in the workspace chat instead of being added to the current expense report. This breaks the expected offline behavior where expenses should be added to the report the user is currently viewing.
What is the root cause of that problem?
The root cause is an inconsistency between how the scan/manual expense flow and the distance expense flow determine whether the user started the expense from within an existing report.
In src/libs/actions/IOU/MoneyRequest.ts, the scan flow at line 304 uses:
Scan flow: Uses !initialTransaction?.isFromGlobalCreate - this flag is set in the transaction draft when initialized via initMoneyRequest and is always reliably available
Distance flow: Uses report?.reportID - this depends on the report object being loaded from Onyx
When offline, the report object from Onyx might not be available or fully loaded (the HOC withWritableReportOrNotFound loads it from ONYXKEYS.COLLECTION.REPORT based on route params). When report?.reportID is undefined, the condition fails and the code falls through to line 626-627 which calls navigateToParticipantPage, effectively treating the expense as if it was started from the global create menu.
The transaction draft, however, correctly has isFromGlobalCreate: false (or undefined) and reportID set to the expense report's ID when initialized from within a report. This data is reliable and available offline.
What changes do you think we should make in order to solve the problem?
Update the condition in handleMoneyRequestStepDistanceNavigation in src/libs/actions/IOU/MoneyRequest.ts at line 512 to use !transaction?.isFromGlobalCreate instead of report?.reportID, making it consistent with the scan flow:
This change ensures that the distance expense flow correctly identifies when the user started the expense from within an existing report (where isFromGlobalCreate is false/undefined) versus from the global create menu (where isFromGlobalCreate is true), regardless of whether the full report object is available in Onyx.
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
When a user is offline and creates a distance expense from an existing expense report (via "Add expense" → "Track distance"), the expense is not added to the existing expense report. Instead, it creates a new separate report in the workspace chat.
What is the root cause of that problem?
The root cause is in the createDistanceRequest function in src/libs/actions/IOU/index.ts. When the user adds a distance expense to an existing expense report, the function extracts the moneyRequestReportID from the passed report object and passes it to getMoneyRequestInformation.
When offline, allReports may not have the expense report loaded/synced, so iouReport becomes null. Then at line 3117-3123, shouldCreateNewMoneyRequestReport returns true because !existingIOUReport is true, and a new report is created instead of using the existing one.
What changes do you think we should make in order to solve the problem?
Instead of only passing moneyRequestReportID (which requires a lookup in allReports), we should pass the expense report object directly as existingIOUReport when it's available. This way, getMoneyRequestInformation can use the report object directly without needing to look it up from allReports.
In src/libs/actions/IOU/index.ts, in the createDistanceRequest function:
This ensures that when the user is adding a distance expense to an existing expense report, the report object is passed directly and used without needing to look it up from allReports, making the offline flow work correctly.
What alternative solutions did you explore? (Optional)
Restate the problem this issue is trying to solve.
When a distance expense is created while offline from an opened expense report, the expense is added to a new report instead of the opened report. This happens on Android when the report exists locally but is not synced.
What is the root cause of that problem?
The earliest wrong assumption is in getMoneyRequestInformation() in src/libs/actions/IOU/index.ts. The code assumes the IOU report will always exist in allReports. This is wrong when offline because the report may exist only in allReportsDraft. The direct lookup returns null, and the function then creates a new report.
What changes do you think we should make in order to solve the problem?
Replace direct allReports access with getReportOrDraftReport() so drafts are checked.
Update both the primary and fallback IOU report lookups.
Keep logic the same. Change only the lookup method.
File:src/libs/actions/IOU/index.ts
// In getMoneyRequestInformation() function, around line 2980-2989// STEP 2: Get the Expense/IOU report.// If the existingIOUReport or moneyRequestReportID has been provided, we want to add the transaction to this specific report.// If no such reportID has been provided, let's use the chatReport.iouReportID property.// In case that is not present, build a new optimistic Expense/IOU report.letiouReport: OnyxInputValue<OnyxTypes.Report>=null;if(existingIOUReport){iouReport=existingIOUReport;}elseif(moneyRequestReportID){iouReport=getReportOrDraftReport(moneyRequestReportID);}elseif(!getReportOrDraftReport(chatReport.iouReportID)?.errorFields?.createChat){iouReport=getReportOrDraftReport(chatReport.iouReportID);}
What alternative solutions did you explore? (Optional)
Sync drafts into allReports when offline. Not chosen because it changes data flow and is larger than needed.
Add special offline checks. Not chosen because it adds new logic instead of using the existing pattern.
Please re-state the problem that we are trying to solve in this issue.
A distance expense created while offline does not appear in the existing expense report. Instead, it shows up in the workspace chat as a separate new report.
What is the root cause of that problem?
In the logic used to determine whether shouldCreateNewMoneyRequestReport is true, we incorrectly evaluate isScanRequest as true:
This happens because the isScanRequestTransactionUtils function expects a full transaction object containing fields like iouRequestType, source, amount, etc.—but we currently only pass {amount, receipt}.
What changes do you think we should make in order to solve the problem?
We should correct how we determine the isScanRequest value. This can be done by either:
Passing iouRequestType: existingTransaction.iouRequestType in the current object, or
Passing the entire existingTransaction instead of just {amount, receipt} at the following location:
Proposal for Issue #80591: Distance Expense Created Offline Not Shown in Expense Report
Problem
When a user creates a distance expense while offline from within an expense report, the expense does not appear in that report. Instead, it is created as a separate new report in the workspace chat.
Root Cause
The issue occurs in the distance expense creation flow in src/libs/actions/IOU/index.ts:
Critical Code Section 1: Report Type Determination
// STEP 2: Get the Expense/IOU report. If the existingIOUReport or moneyRequestReportID has been provided, we want to add the transaction to this specific report.
// If no such reportID has been provided, let's use the chatReport.iouReportID property. In case that is not present, build a new optimistic Expense/IOU report.
// STEP 2: Get the Expense/IOU report. If the existingIOUReport or moneyRequestReportID has been provided, we want to add the transaction to this specific report.// If no such reportID has been provided, let's use the chatReport.iouReportID property. In case that is not present, build a new optimistic Expense/IOU report.letiouReport: OnyxInputValue<OnyxTypes.Report>=null;if(existingIOUReport){iouReport=existingIOUReport;}elseif(moneyRequestReportID){iouReport=allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReportID}`]??null;}elseif(!allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`]?.errorFields?.createChat){iouReport=allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`]??null;}
When offline, if the expense report isn't in the allReports cache:
The lookup at line 3137 fails (returns null)
A NEW optimistic IOU report is created instead of using the intended expense report
Why This Happens Offline
When offline, the expense report object may not be in the Onyx cache (allReports). The code at line 3137 attempts to look up the report by ID from the cache, which fails. The code then falls through to create a new optimistic report rather than using the expense report that was passed in.
Solution
Approach
Pass the expense report object directly to getMoneyRequestInformation when creating a distance expense from within an expense report, rather than relying on looking it up in the cache. This ensures the report is used even when offline.
Implementation Plan
Change 1: Add expenseReport parameter to type definition
File: src/libs/actions/IOU/index.ts
Location: Line 544-572 (MoneyRequestInformationParams type)
Add expenseReport parameter after moneyRequestReportID:
typeMoneyRequestInformationParams={parentChatReport: OnyxEntry<OnyxTypes.Report>;existingIOUReport?: OnyxEntry<OnyxTypes.Report>;transactionParams: RequestMoneyTransactionParams;participantParams: RequestMoneyParticipantParams;policyParams?: BasePolicyParams;moneyRequestReportID?: string;expenseReport?: OnyxEntry<OnyxTypes.Report>;// NEW PARAMETER// ... rest of params
Change 2: Update report lookup logic in getMoneyRequestInformation
Update the IOU report lookup to check for expenseReport before checking cache:
// STEP 2: Get the Expense/IOU report. If the existingIOUReport, moneyRequestReportID, or expenseReport has been provided, we want to add the transaction to this specific report.// If no such reportID has been provided, let's use the chatReport.iouReportID property. In case that is not present, build a new optimistic Expense/IOU report.letiouReport: OnyxInputValue<OnyxTypes.Report>=null;if(existingIOUReport){iouReport=existingIOUReport;}elseif(expenseReport){// Use the expense report directly when provided (e.g., when creating distance expense from within an expense report)iouReport=expenseReport;}elseif(moneyRequestReportID){iouReport=allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReportID}`]??null;}elseif(!allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`]?.errorFields?.createChat){iouReport=allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${chatReport.iouReportID}`]??null;}
Change 3: Pass expenseReport from createDistanceRequest
changed the title [-][$250] Expense - Distance expense created in offline is not shown in expense report[/-][+][Due for payment 2026-03-04] [$250] Expense - Distance expense created in offline is not shown in expense report[/+]on Feb 25, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.25-13 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@suneox / @truph01@greg-schroeder The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero 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]
Activity
melvin-bot commentedon Jan 27, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @suneox (
External)melvin-bot commentedon Jan 27, 2026
Triggered auto assignment to @greg-schroeder (
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.MobileMage commentedon Jan 27, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user is inside an existing expense report and creates a distance expense while offline, the expense is incorrectly created as a new separate report in the workspace chat instead of being added to the current expense report. This breaks the expected offline behavior where expenses should be added to the report the user is currently viewing.
What is the root cause of that problem?
The root cause is an inconsistency between how the scan/manual expense flow and the distance expense flow determine whether the user started the expense from within an existing report.
In
src/libs/actions/IOU/MoneyRequest.ts, the scan flow at line 304 uses:However, the distance flow at line 512 uses:
The difference is:
!initialTransaction?.isFromGlobalCreate- this flag is set in the transaction draft when initialized viainitMoneyRequestand is always reliably availablereport?.reportID- this depends on thereportobject being loaded from OnyxWhen offline, the
reportobject from Onyx might not be available or fully loaded (the HOCwithWritableReportOrNotFoundloads it fromONYXKEYS.COLLECTION.REPORTbased on route params). Whenreport?.reportIDis undefined, the condition fails and the code falls through to line 626-627 which callsnavigateToParticipantPage, effectively treating the expense as if it was started from the global create menu.The transaction draft, however, correctly has
isFromGlobalCreate: false(or undefined) andreportIDset to the expense report's ID when initialized from within a report. This data is reliable and available offline.What changes do you think we should make in order to solve the problem?
Update the condition in
handleMoneyRequestStepDistanceNavigationinsrc/libs/actions/IOU/MoneyRequest.tsat line 512 to use!transaction?.isFromGlobalCreateinstead ofreport?.reportID, making it consistent with the scan flow:Before (line 512):
After:
This change ensures that the distance expense flow correctly identifies when the user started the expense from within an existing report (where
isFromGlobalCreateis false/undefined) versus from the global create menu (whereisFromGlobalCreateis true), regardless of whether the full report object is available in Onyx.What alternative solutions did you explore? (Optional)
daledah commentedon Jan 27, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user is offline and creates a distance expense from an existing expense report (via "Add expense" → "Track distance"), the expense is not added to the existing expense report. Instead, it creates a new separate report in the workspace chat.
What is the root cause of that problem?
The root cause is in the
createDistanceRequestfunction insrc/libs/actions/IOU/index.ts. When the user adds a distance expense to an existing expense report, the function extracts themoneyRequestReportIDfrom the passedreportobject and passes it togetMoneyRequestInformation.App/src/libs/actions/IOU/index.ts
Lines 7474 to 7477 in bd8a9dc
Inside
getMoneyRequestInformation, themoneyRequestReportIDis used to look up the expense report fromallReports:App/src/libs/actions/IOU/index.ts
Lines 3110 to 3111 in bd8a9dc
When offline,
allReportsmay not have the expense report loaded/synced, soiouReportbecomesnull. Then at line 3117-3123,shouldCreateNewMoneyRequestReportreturnstruebecause!existingIOUReportis true, and a new report is created instead of using the existing one.What changes do you think we should make in order to solve the problem?
Instead of only passing
moneyRequestReportID(which requires a lookup inallReports), we should pass the expense report object directly asexistingIOUReportwhen it's available. This way,getMoneyRequestInformationcan use the report object directly without needing to look it up fromallReports.In
src/libs/actions/IOU/index.ts, in thecreateDistanceRequestfunction:This ensures that when the user is adding a distance expense to an existing expense report, the report object is passed directly and used without needing to look it up from
allReports, making the offline flow work correctly.What alternative solutions did you explore? (Optional)
yatin-italy commentedon Jan 27, 2026
Proposal
Restate the problem this issue is trying to solve.
When a distance expense is created while offline from an opened expense report, the expense is added to a new report instead of the opened report. This happens on Android when the report exists locally but is not synced.
What is the root cause of that problem?
The earliest wrong assumption is in
getMoneyRequestInformation()insrc/libs/actions/IOU/index.ts. The code assumes the IOU report will always exist inallReports. This is wrong when offline because the report may exist only inallReportsDraft. The direct lookup returnsnull, and the function then creates a new report.What changes do you think we should make in order to solve the problem?
allReportsaccess withgetReportOrDraftReport()so drafts are checked.File:
src/libs/actions/IOU/index.tsWhat alternative solutions did you explore? (Optional)
allReportswhen offline. Not chosen because it changes data flow and is larger than needed.truph01 commentedon Jan 27, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
In the logic used to determine whether
shouldCreateNewMoneyRequestReportistrue, we incorrectly evaluateisScanRequestastrue:App/src/libs/actions/IOU/index.ts
Line 3116 in 68eaf86
App/src/libs/ReportUtils.ts
Line 11051 in 68eaf86
This happens because the
isScanRequestTransactionUtilsfunction expects a fulltransactionobject containing fields likeiouRequestType,source,amount, etc.—but we currently only pass{amount, receipt}.What changes do you think we should make in order to solve the problem?
We should correct how we determine the
isScanRequestvalue. This can be done by either:iouRequestType: existingTransaction.iouRequestTypein the current object, orexistingTransactioninstead of just{amount, receipt}at the following location:App/src/libs/actions/IOU/index.ts
Line 3116 in 68eaf86
We should also check and update other call sites as needed to ensure consistency.
What alternative solutions did you explore? (Optional)
HiepPP commentedon Jan 27, 2026
Proposal for Issue #80591: Distance Expense Created Offline Not Shown in Expense Report
Problem
When a user creates a distance expense while offline from within an expense report, the expense does not appear in that report. Instead, it is created as a separate new report in the workspace chat.
Root Cause
The issue occurs in the distance expense creation flow in
src/libs/actions/IOU/index.ts:Critical Code Section 1: Report Type Determination
In
createDistanceRequestat lines 7508-7511:App/src/libs/actions/IOU/index.ts
Lines 7508 to 7511 in 2abd327
When creating a distance expense from within an expense report:
reportis the expense report objectisMoneyRequestReportevaluates totrue(expense reports are money request reports)moneyRequestReportIDis set to the expense report's IDcurrentChatReportis set to the expense report's linked chat reportCritical Code Section 2: Report Lookup Logic
In
getMoneyRequestInformationat lines 3131-3140:App/src/libs/actions/IOU/index.ts
Lines 3131 to 3140 in 2abd327
When offline, if the expense report isn't in the
allReportscache:null)Why This Happens Offline
When offline, the expense report object may not be in the Onyx cache (
allReports). The code at line 3137 attempts to look up the report by ID from the cache, which fails. The code then falls through to create a new optimistic report rather than using the expense report that was passed in.Solution
Approach
Pass the expense report object directly to
getMoneyRequestInformationwhen creating a distance expense from within an expense report, rather than relying on looking it up in the cache. This ensures the report is used even when offline.Implementation Plan
Change 1: Add
expenseReportparameter to type definitionFile:
src/libs/actions/IOU/index.tsLocation: Line 544-572 (MoneyRequestInformationParams type)
Add
expenseReportparameter aftermoneyRequestReportID:Change 2: Update report lookup logic in
getMoneyRequestInformationFile:
src/libs/actions/IOU/index.tsLocation: Lines 3131-3140
Update the IOU report lookup to check for
expenseReportbefore checking cache:Change 3: Pass
expenseReportfromcreateDistanceRequestFile:
src/libs/actions/IOU/index.tsLocation: Lines 7598-7636 (getMoneyRequestInformation call)
Add
expenseReportparameter when callinggetMoneyRequestInformation:Why This Works
isMoneyRequestReportistrue, we have the expense report object in thereportparameterexpenseReport, we bypass the cache lookupgetMoneyRequestInformationfunction uses the provided report directly, avoiding the need for cache lookupEdge Cases Handled
isMoneyRequestReportisfalse, soexpenseReportremainsundefinedand the existing logic is usedexpenseReportwhen the report is a money request report (IOU or expense report)Files Modified
src/libs/actions/IOU/index.tsexpenseReporttoMoneyRequestInformationParamstype (line ~551)getMoneyRequestInformationfunction (lines 3131-3140)expenseReportparameter increateDistanceRequest(line ~7601)Testing Approach
Offline distance expense from expense report
Online distance expense from expense report
Chat-based distance expense
Track expense flow
Different report types
Alternative Approaches Considered
Alternative 1: Cache the expense report before creating the distance expense
Rejected because:
Alternative 2: Use draft reports collection
Rejected because:
Alternative 3: Modify
getReportOrDraftReportto accept the report directlyRejected because:
Potential Risks and Mitigations
Risk: Breaking chat-based distance expenses
expenseReportwhenisMoneyRequestReportistrue. Chat-based flows continue using existing logic.Risk: Creating invalid report references
createDistanceRequest. We're ensuring it's used rather than looked up.Risk: Issues with report totals
References
suneox commentedon Jan 30, 2026
Thanks for all proposals. I'll take a look at this one today
27 remaining items
[-][$250] Expense - Distance expense created in offline is not shown in expense report[/-][+][Due for payment 2026-03-04] [$250] Expense - Distance expense created in offline is not shown in expense report[/+]melvin-bot commentedon Feb 25, 2026
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Feb 25, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.3.25-13 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-03-04. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Feb 25, 2026
@suneox / @truph01 @greg-schroeder The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero 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]
greg-schroeder commentedon Mar 6, 2026
Payment summary:
Author: @truph01 - $250 - ND manual request
Reviewer: @suneox - $250 - ND manual request
Approved for payments as outlined above ☝️
trjExpensify commentedon Mar 6, 2026
approved $250 for @suneox
JmillsExpensify commentedon Mar 18, 2026
$250 approved for @truph01