Skip to content

[$500] Web - IOU - TBD shows up for preview component after uploading picture as receipt and deleting it #33935

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.21-1
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. Open a conversation
  2. Click on plus icon inside composer
  3. Click on request money > Scan receipt
  4. Upload a picture which is not a receipt
  5. Finish the IOU flow and wait for the scan to finish
  6. After the scan finished and an error shows up go inside the IOU details page and delete the request
  7. Go back to the report

Expected Result:

TBD should not show as the preview component for the iou

Actual Result:

The IOU preview component turns to TBD

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

Bug6331902_1704349549835.tbd.mp4

View all open jobs on GitHub

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

Activity

  1. added
    External
    Daily
    Bug
    on Jan 4, 2024
  2. melvin-bot commented on Jan 4, 2024

    @melvin-bot
  3. changed the title [-]Web - IOU - TBD shows up for preview component after uploading picture as receipt and deleting it[/-] [+][$500] Web - IOU - TBD shows up for preview component after uploading picture as receipt and deleting it[/+] on Jan 4, 2024
  4. melvin-bot commented on Jan 4, 2024

    @melvin-bot

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

  5. added
    Help Wanted
    on Jan 4, 2024
  6. melvin-bot commented on Jan 4, 2024

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Jan 4, 2024

    @melvin-bot

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

  8. paultsimura commented on Jan 4, 2024

    @paultsimura
    Contributor

    Proposal

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

    When the IOU Report contains only removed requests, the total is shown as TBD.

    What is the root cause of that problem?

    When calculating whether to show TBD on the IOU Report view, we use the hasOnlyDistanceRequestTransactions function. It returns true if the transactions list is empty, which is incorrect:

    App/src/libs/ReportUtils.ts

    Lines 980 to 987 in 3b424bb

    /**
    * Checks whether all the transactions linked to the IOU report are of the Distance Request type
    *
    */
    function hasOnlyDistanceRequestTransactions(iouReportID: string | undefined): boolean {
    const transactions = TransactionUtils.getAllReportTransactions(iouReportID);
    return transactions.every((transaction) => TransactionUtils.isDistanceRequest(transaction));
    }

    const formattedTotalAmount = CurrencyUtils.convertToDisplayString(totalDisplaySpend, report.currency, ReportUtils.hasOnlyDistanceRequestTransactions(report.reportID));

    function convertToDisplayString(amountInCents = 0, currency: string = CONST.CURRENCY.USD, shouldFallbackToTbd = false): string {
    if (shouldFallbackToTbd && !amountInCents) {
    return Localize.translateLocal('common.tbd');
    }

    In our case, the transactions list is empty because when removing a failed scan request, we remove the transactions, but not the transaction threads (since they contain in-thread message from __fake__ (or notifications) account about the failed scan).

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

    Modify the hasOnlyDistanceRequestTransactions function to return false if there are no transactions (it was broken during the TS migration):

    return !!transactions.length && transactions.every((transaction) => TransactionUtils.isDistanceRequest(transaction));

    Result:

    image

    What alternative solutions did you explore? (Optional)

  9. rojiphil commented on Jan 4, 2024

    @rojiphil
    Contributor

    This issue is been addressed in this PR
    We can either put this on hold or close this
    cc @fedirjh

  10. fedirjh commented on Jan 4, 2024

    @fedirjh
    Contributor

    Agree with @rojiphil , this should be fixed with #32698.

  11. NicMendonca commented on Jan 4, 2024

    @NicMendonca
    Contributor

    thanks both! closing for now

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

Metadata

Metadata

Labels

BugDailyExternalHelp Wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions