Skip to content

[$500] Smartscan: Expense report preview in LHN shows 0.00 when PDF receipt is scanned successfully #34178

Closed

Description

@kbecciv

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: 1.4.23-0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Go to workspace chat.
  2. Create a Scan request with PDF file as receipt.
  3. When the scanning is complete, open expense report.

Expected Result:

Expense report preview in LHN shows the correct amount.

Actual Result:

Expense report preview in LHN shows 0.00.
This issue is only reproducible when PDF receipt is used.

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e635178117bbd335
  • Upwork Job ID: 1744794404061753344
  • Last Price Increase: 2024-01-30

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jan 9, 2024
  2. changed the title [-]Scan - Expense report preview in LHN shows 0.00 when PDF receipt is scanned successfully[/-] [+][$500] Scan - Expense report preview in LHN shows 0.00 when PDF receipt is scanned successfully[/+] on Jan 9, 2024
  3. melvin-bot commented on Jan 9, 2024

    @melvin-bot
  4. melvin-bot commented on Jan 9, 2024

    @melvin-bot

    Triggered auto assignment to @JmillsExpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jan 9, 2024
  6. melvin-bot commented on Jan 9, 2024

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @fedirjh (External)

  7. Tony-MK commented on Jan 9, 2024

    @Tony-MK
    Contributor

    I think this issue is related to #34064

  8. dummy-1111 commented on Jan 9, 2024

    @dummy-1111
    Contributor

    This issue is related to the sidebar and I don't think this is related to #34064

  9. Tony-MK commented on Jan 9, 2024

    @Tony-MK
    Contributor

    @s-alves10 In this #34064 (comment), Tim Golden instructed.

    The LHN and the preview should be using the same logic

    If it is not related, then it should be fixed by #34064.

    What do you think? 🤔

  10. dummy-1111 commented on Jan 9, 2024

    @dummy-1111
    Contributor

    Proposal

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

    LHN shows 0.00 for IOU report when receipt is scanned successfully

    What is the root cause of that problem?

    Let's take a look at getReportPreviewMessage function which is used for displaying second line of LHN

    For money request, we get the preview message here

    App/src/libs/ReportUtils.ts

    Lines 2140 to 2148 in 3acb14a

    if (originalMessage?.amount !== undefined && lastActorID && !isPreviewMessageForParentChatReport) {
    const amount = originalMessage?.amount;
    const currency = originalMessage?.currency ?? report.currency ?? '';
    const amountToDisplay = CurrencyUtils.convertToDisplayString(Math.abs(amount), currency);
    // We only want to show the actor name in the preview if it's not the current user who took the action
    const requestorName = lastActorID && lastActorID !== currentUserAccountID ? getDisplayNameForParticipant(lastActorID, !isPreviewMessageForParentChatReport) : '';
    return `${requestorName ? `${requestorName}: ` : ''}${Localize.translateLocal('iou.requestedAmount', {formattedAmount: amountToDisplay})}`;
    }

    We get the preview message from the original message amount and report currency.

    This is the root cause

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

    We should get the preview message from the transaction details

    We are already doing this for split bill actions here

    App/src/libs/ReportUtils.ts

    Lines 2067 to 2087 in 3acb14a

    if (isNotEmptyObject(reportAction) && !isIOUReport(report) && reportAction && ReportActionsUtils.isSplitBillAction(reportAction)) {
    // This covers group chats where the last action is a split bill action
    const linkedTransaction = TransactionUtils.getLinkedTransaction(reportAction);
    if (isEmptyObject(linkedTransaction)) {
    return reportActionMessage;
    }
    if (isNotEmptyObject(linkedTransaction)) {
    if (TransactionUtils.isReceiptBeingScanned(linkedTransaction)) {
    return Localize.translateLocal('iou.receiptScanning');
    }
    if (TransactionUtils.hasMissingSmartscanFields(linkedTransaction)) {
    return Localize.translateLocal('iou.receiptMissingDetails');
    }
    const transactionDetails = getTransactionDetails(linkedTransaction);
    const formattedAmount = CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency ?? '');
    return Localize.translateLocal('iou.didSplitAmount', {formattedAmount, comment: transactionDetails?.comment ?? ''});
    }
    }

    Update the above code segments to

        if (isNotEmptyObject(reportAction) && reportAction && ReportActionsUtils.isMoneyRequestAction(reportAction)) {
            // This covers group chats where the last action is a split bill action
            const linkedTransaction = TransactionUtils.getLinkedTransaction(reportAction);
            if (isEmptyObject(linkedTransaction)) {
                return reportActionMessage;
            }
    
            if (isNotEmptyObject(linkedTransaction)) {
                if (TransactionUtils.isReceiptBeingScanned(linkedTransaction)) {
                    return Localize.translateLocal('iou.receiptScanning');
                }
    
                if (TransactionUtils.hasMissingSmartscanFields(linkedTransaction)) {
                    return Localize.translateLocal('iou.receiptMissingDetails');
                }
    
                const transactionDetails = getTransactionDetails(linkedTransaction);
                const formattedAmount = CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency ?? '');
                if (!isIOUReport(report) && ReportActionsUtils.isSplitBillAction(reportAction)) {
                    return Localize.translateLocal('iou.didSplitAmount', {formattedAmount, comment: transactionDetails?.comment ?? ''});
                } else {
                    const lastActorID = reportAction?.actorAccountID;
                    const requestorName = lastActorID && lastActorID !== currentUserAccountID ? getDisplayNameForParticipant(lastActorID, !isPreviewMessageForParentChatReport) : '';
                    return `${requestorName ? `${requestorName}: ` : ''}${Localize.translateLocal('iou.requestedAmount', {formattedAmount})}`;
                }
            }
        }
    

    This works great

    Result

    image

    What alternative solutions did you explore? (Optional)

  11. dummy-1111 commented on Jan 9, 2024

    @dummy-1111
    Contributor

    @Tony-MK

    #34064 is related to IOU report preview in chat report and LHN for the report
    This issue is related to money request in IOU report and LHN for the IOU report
    They are different.

  12. 77 remaining items

  13. Gonals commented on Mar 11, 2024

    @Gonals
    Contributor

    Closing, then!

  14. moved this from Release 1: Spring 2024 (May) to Done in [#whatsnext] #wave-collecton Mar 11, 2024
  15. lanitochka17 commented on Aug 8, 2024

    @lanitochka17

    Issue is still reproducible on the latest build 9.0.18-1

    20240808_204303.mp4
  16. melvin-bot commented on Aug 13, 2024

    @melvin-bot

    @JmillsExpensify, @Gonals, @fedirjh Huh... This is 4 days overdue. Who can take care of this?

  17. JmillsExpensify commented on Aug 14, 2024

    @JmillsExpensify
    Contributor

    Can we create a fresh issue for this?

  18. Gonals commented on Aug 19, 2024

    @Gonals
    Contributor

    I can't seem to reproduce this (once again). Closing for now 🤷

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringInternalRequires API changes or must be handled by Expensify staff

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions