Skip to content

Manual Distance Expense incorrectly labeled as Odometer Distance Expense #82991

@Julesssss

Description

@Julesssss

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)

  1. Create an odometer distance expense
  2. Start creating a new distance expense and select the manual tab
  3. The expense may be incorrectly labeled as odometer

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions