Skip to content

Expense - Merchant & Amount show "Scanning" when distance is submitted from self DM offline #82960

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.22-3
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-5661/folder/13176877/41237352/1198787360
Email or phone of affected tester (no customers): dsjoinsjdiosdjsoijdis@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Have at least one workspace.
  1. Go to staging.new.expensify.com
  2. Go to self DM.
  3. Go offline.
  4. Create a map distance expense.
  5. Click Submit it to someone.
  6. Select workspace chat.
  7. On confirm page, click Rate.
  8. Select any rate.
  9. Click Create expense.
  10. Create one more expense (any type) in the workspace chat.
  11. Open the expense report.

Expected Result:

On the distance expense row, Merchant will show "Pending", Amount will show 0.00.

Actual Result:

On the distance expense row, Merchant and Amount field show "Scanning".

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7082578_1771517058803.8.mp4

View all open jobs on GitHub

Activity

  1. Burhan-Rashid commented on Feb 22, 2026

    @Burhan-Rashid
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Expense - Merchant & Amount show "Scanning" when distance is submitted from self DM offline

    What is the root cause of that problem?

    When we create the distance request on map in offline mode, the distanceInMeters is 0 and since we are creating distance-map request(on map) and not a manual distance request. So the function getDistanceMerchant returns empty string here as both the conditions (!distanceInMeters && !isManualDistanceRequest) are satisfied here:

    function getDistanceMerchant(
    hasRoute: boolean,
    distanceInMeters: number,
    unit: Unit | undefined,
    rate: number | undefined,
    currency: string,
    translate: LocaleContextProps['translate'],
    toLocaleDigit: LocaleContextProps['toLocaleDigit'],
    getCurrencySymbol: CurrencyListActionsContextType['getCurrencySymbol'],
    isManualDistanceRequest?: boolean,
    ): string {
    if (!hasRoute || !rate) {
    return translate('iou.fieldPending');
    }
    if (!distanceInMeters && !isManualDistanceRequest) {
    return '';
    }

    getDistanceMerchant is called here inside getMerchant function:
    function getMerchant(transaction: OnyxInputOrEntry<Transaction>, policyParam: OnyxEntry<Policy> = undefined): string {
    if (transaction && isDistanceRequest(transaction)) {
    const report = getReportOrDraftReport(transaction.reportID);
    // This will be fixed as part of https://github.com/Expensify/Expensify/issues/507850
    // eslint-disable-next-line @typescript-eslint/no-deprecated
    const policy = policyParam ?? getPolicy(report?.policyID);
    const mileageRate = DistanceRequestUtils.getRate({transaction, policy});
    const {unit, rate} = mileageRate;
    const distanceInMeters = getDistanceInMeters(transaction, unit);
    if (
    (policy?.customUnits && !isUnreportedAndHasInvalidDistanceRateTransaction(transaction, policy)) ||
    // If modifiedMerchant is empty but modifiedCurrency exists, recalculate the merchant
    (!transaction?.modifiedMerchant && transaction?.modifiedCurrency)
    ) {
    return DistanceRequestUtils.getDistanceMerchant(
    true,
    distanceInMeters,
    unit,
    rate,
    getCurrency(transaction),
    // eslint-disable-next-line @typescript-eslint/no-deprecated
    translateLocal,
    (digit) => toLocaleDigit(IntlStore.getCurrentLocale(), digit),
    getCurrencySymbol,
    isManualDistanceRequest(transaction),
    );

    Which is inturn called in here for checking isPartialTransaction:
    function isPartialTransaction(transaction: OnyxEntry<Transaction>): boolean {
    const merchant = getMerchant(transaction);
    if (!merchant || isPartialMerchant(merchant)) {
    return true;
    }

    Which makes the condition for isPartialTransaction as true above.
    Which makes the isScanning function to return true as both isPartialTransaction(transaction) && hasReceipt(transaction) true because we already attach dummy receipt for distance requests while creating.
    function isScanning(transaction: OnyxEntry<Transaction>): boolean {
    // Performance optimization: Check the receipt state first (cheapest check) before doing more expensive checks
    if (!isReceiptBeingScanned(transaction)) {
    return false;
    }
    return isPartialTransaction(transaction) && hasReceipt(transaction);
    }

    Since we get true for isScanning function, out total cell renders 'scanning' here:

    if (isScanning(transactionItem)) {
    amountToDisplay = translate('iou.receiptStatusTitle');
    }

    For merchant cell, we get the value of merchant from here, where also the same conditions make us set merchant to scanning instead of pending.

    if (isScanning(transactionItem) && shouldShowMerchant) {
    merchant = translate('iou.receiptStatusTitle');
    }

    What changes do you think we should make in order to solve the problem?

    We already have the value of transaction.merchant as pending, so we need to use transaction.merchant as a fallback when we are having distance request and when getMerchant function returns emtpy string. For that we can make the following changes here:

    index 6c94ba837b4..50409a9fcf9 100644
    --- a/src/components/TransactionItemRow/index.tsx
    +++ b/src/components/TransactionItemRow/index.tsx
    @@ -38,6 +38,7 @@ import {
         getCreated as getTransactionCreated,
         hasMissingSmartscanFields,
         isAmountMissing,
    +    isDistanceRequest,
         isMerchantMissing,
         isScanning,
         isTimeRequest,
    @@ -145,10 +146,14 @@ function getMerchantName(transactionItem: TransactionWithOptionalSearchFields, t
     
         let merchant = transactionItem?.formattedMerchant ?? getMerchant(transactionItem);
     
    -    if (isScanning(transactionItem) && shouldShowMerchant) {
    +    if (isScanning(transactionItem) && shouldShowMerchant && !isDistanceRequest(transactionItem)) {
             merchant = translate('iou.receiptStatusTitle');
         }
     
    +    if (!merchant && isDistanceRequest(transactionItem)) {
    +        merchant = transactionItem.merchant ?? '';
    +    }
    +
         const merchantName = StringUtils.getFirstLine(merchant);
         return merchantName !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT && merchantName !== CONST.TRANSACTION.DEFAULT_MERCHANT ? merchantName : '';
     }

    And for total cell add the condition to check for distance request, and only show scanning if it is not a distance request here:

    index 5c5248cff74..fa84c0d2447 100644
    --- a/src/components/TransactionItemRow/DataCells/TotalCell.tsx
    +++ b/src/components/TransactionItemRow/DataCells/TotalCell.tsx
    @@ -4,7 +4,7 @@ import useLocalize from '@hooks/useLocalize';
     import useThemeStyles from '@hooks/useThemeStyles';
     import {convertToDisplayString} from '@libs/CurrencyUtils';
     import {getTransactionDetails} from '@libs/ReportUtils';
    -import {getCurrency as getTransactionCurrency, isScanning} from '@libs/TransactionUtils';
    +import {getCurrency as getTransactionCurrency, isDistanceRequest, isScanning} from '@libs/TransactionUtils';
     import type TransactionDataCellProps from './TransactionDataCellProps';
     
     function TotalCell({shouldShowTooltip, transactionItem}: TransactionDataCellProps) {
    @@ -14,7 +14,7 @@ function TotalCell({shouldShowTooltip, transactionItem}: TransactionDataCellProp
     
         const amount = getTransactionDetails(transactionItem)?.amount;
         let amountToDisplay = convertToDisplayString(amount, currency);
    -    if (isScanning(transactionItem)) {
    +    if (isScanning(transactionItem) && !isDistanceRequest(transactionItem)) {
             amountToDisplay = translate('iou.receiptStatusTitle');
         }

    What alternative solutions did you explore? (Optional)

    Alternate solution 1:
    We can also change the condition inside the isScanning function to check for distance requests, return false always if it is a distance request as distance requests are never scanned. For that we can make the following changes here:

    function isScanning(transaction: OnyxEntry<Transaction>): boolean {
        // Performance optimization: Check the receipt state first (cheapest check) before doing more expensive checks
        if (!isReceiptBeingScanned(transaction)) {
            return false;
        }
    
        return !isDistanceRequest(transaction) && isPartialTransaction(transaction) && hasReceipt(transaction);
    }

    function isScanning(transaction: OnyxEntry<Transaction>): boolean {
    // Performance optimization: Check the receipt state first (cheapest check) before doing more expensive checks
    if (!isReceiptBeingScanned(transaction)) {
    return false;
    }
    return isPartialTransaction(transaction) && hasReceipt(transaction);
    }

    And here, we still need to fallback to transactionItem.merchant for distance request when getMerchant return '', so we need to make the following changes here:

     if (!merchant && isDistanceRequest(transactionItem)) {
            merchant = transactionItem.merchant ?? '';
        }

    Image

    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.

  2. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    10 days overdue. Is anyone even seeing these? Hello?

  3. melvin-bot commented on Mar 10, 2026

    @melvin-bot

    This issue has not been updated in over 14 days. eroding to Weekly issue.

  4. melvin-bot commented on Apr 2, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. 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!

  5. melvin-bot commented on Jun 15, 2026

    @melvin-bot

    @lanitochka17, this Monthly task hasn't been acted upon in 6 weeks; closing.

    If you disagree, feel encouraged to reopen it -- but pick your least important issue to close instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions