-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Manual Distance Expense incorrectly labeled as Odometer Distance Expense #82991
Description
Problem
When creating a manual distance expense after previously creating an odometer distance expense, the new expense can sometimes be mislabeled as "odometer" instead of "manual". Once this happens, all subsequent manual distance expenses are also mislabeled, creating a loop.
Hard to reproduce — only reproduced twice across several hours of testing.
Suspected cause
In src/pages/iou/request/DistanceRequestStartPage.tsx:89, lastDistanceExpenseType takes priority over selectedTab in the fallback chain:
const transactionRequestType = useMemo(() => {
if (!transaction?.iouRequestType) {
return lastDistanceExpenseType ?? selectedTab ?? CONST.IOU.REQUEST_TYPE.DISTANCE_MAP;
}
return transaction.iouRequestType;
}, [transaction?.iouRequestType, selectedTab, lastDistanceExpenseType]);When lastDistanceExpenseType is distance-odometer and selectedTab is distance-manual, the odometer value wins because it is checked first in the nullish coalescing chain.
Expected behavior
Selecting the "manual" distance tab and creating an expense should always produce a manual distance expense, regardless of what the previous expense type was.
Repro steps (uncomfirmed)
- Create an odometer distance expense
- Start creating a new distance expense and select the manual tab
- The expense may be incorrectly labeled as odometer