Skip to content

[$250] Scan - LHN preview for expense report shows 0.00 when there is only one scan expense #47843

Closed

Description

@IuliiaHerets

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: v9.0.23-0
Reproducible in staging?: Y
Reproducible in production?: Y
Issue reported by: Applause Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat that has no unsettled expense (or create a new workspace).
  3. Submit a scan expense.
  4. After the scanning is complete, click on the expense preview in the main chat.

Expected Result:

LHN preview for the expense report will show the correct scanned amount.

Actual Result:

LHN preview for the expense report shows 0.00.
This issue only happens when there is only one scan expense in the report.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6579036_1724311933885.20240822_152830.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01676bf97c74d0768c
  • Upwork Job ID: 1826760340462476516
  • Last Price Increase: 2024-08-22
  • Automatic offers:
    • DylanDylann | Reviewer | 103712163
    • nkdengineer | Contributor | 103712164
Issue OwnerCurrent Issue Owner: @DylanDylann

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 22, 2024
  2. melvin-bot commented on Aug 22, 2024

    @melvin-bot

    Triggered auto assignment to @twisterdotcom (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. IuliiaHerets commented on Aug 22, 2024

    @IuliiaHerets
    Author

    We think that this bug might be related to #wave-collect - Release 1

  4. IuliiaHerets commented on Aug 22, 2024

    @IuliiaHerets
    Author

    @twisterdotcom FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

  5. bernhardoj commented on Aug 22, 2024

    @bernhardoj
    Contributor

    Proposal

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

    LHN last message shows 0 amount in one-expense report if the expense is a scan request.

    What is the root cause of that problem?

    The one-expense report "lastMessageText" itself is "$0.00 expense". Looks like the last message when we do a scan request is always like that. But if we open an empty transaction thread, the last message shown in LHN is "No activity yet". I believe we want the last message for one-expense report to be the same as transaction thread, so I'll explain why the last message shown in LHN is different.

    When we get the last message of a report, we take its last visible action and we create it based on the action type.

    function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails: Partial<PersonalDetails> | null, policy?: OnyxEntry<Policy>): string {
    const reportID = report?.reportID ?? '-1';
    const lastReportAction = lastVisibleReportActions[reportID] ?? null;

    If the last message is still empty, we fallback to the report lastMessageText property.

    } else if (lastReportAction?.actionName === 'EXPORTINTEGRATION') {
    lastMessageTextFromReport = ReportActionUtils.getExportIntegrationLastMessageText(lastReportAction);
    } else if (lastReportAction?.actionName && ReportActionUtils.isOldDotReportAction(lastReportAction)) {
    lastMessageTextFromReport = ReportActionUtils.getMessageOfOldDotReportAction(lastReportAction, false);
    }
    return lastMessageTextFromReport || (report?.lastMessageText ?? '');

    In one-expense report, the last report action is null because the last report action is the CREATED action, but we filter it out, so, it fallback to the lastMessageText which is "$0.00 expense".

    This is the same case as one-transaction thread too, but the lastMessageText is empty, so, it gets the last message from the welcome message, which is also empty for a chat thread (including transaction thread), so we finally fallback to "No activity yet".

    if (!lastMessageText) {
    lastMessageText = ReportUtils.formatReportLastMessageText(getWelcomeMessage(report, policy).messageText ?? Localize.translateLocal('report.noActivityYet'));

    function getWelcomeMessage(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>): WelcomeMessage {
    const welcomeMessage: WelcomeMessage = {showReportName: true};
    if (ReportUtils.isChatThread(report) || ReportUtils.isTaskReport(report)) {
    return welcomeMessage;
    }

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

    To show "No activity yet" for one-expense report too,

    1. If it's a one-transaction report and the last report action is empty (null), then return empty string as the last message from OptionsListUtils.getLastMessageTextForReport.
    if (!lastReportAction && transactionThreadReportIDs[reportID]) {
        return "";
    } else if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) {
    

    transactionThreadReportIDs is a new variable that stores the one-transaction thread report ID for each one-expense report.

    const transactionThreadReportIDs = {};
    

    const transactionThreadReportID = ReportActionUtils.getOneTransactionThreadReportID(reportID, actions[reportActions[0]]);
    if (transactionThreadReportID) {
    const transactionThreadReportActionsArray = Object.values(actions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {});
    sortedReportActions = ReportActionUtils.getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, reportID);
    }

    transactionThreadReportIDs[reportID] = transactionThreadReportID;
    
    1. Update getWelcomeMessage to return empty welcome message for one-expense report too.
      function getWelcomeMessage(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>): WelcomeMessage {
      const welcomeMessage: WelcomeMessage = {showReportName: true};
      if (ReportUtils.isChatThread(report) || ReportUtils.isTaskReport(report)) {
      return welcomeMessage;
      }
     || !!ReportActionsUtils.getOneTransactionThreadReportID(report?.reportID ?? '-1', reportActions)
    

    We will pass the reportActions as the param of getWelcomeMessage.

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 22, 2024
  7. changed the title [-]Scan - LHN preview for expense report shows 0.00 when there is only one scan expense[/-] [+][$250] Scan - LHN preview for expense report shows 0.00 when there is only one scan expense[/+] on Aug 22, 2024
  8. melvin-bot commented on Aug 22, 2024

    @melvin-bot
  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 22, 2024
  10. melvin-bot commented on Aug 22, 2024

    @melvin-bot

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

  11. nkdengineer commented on Aug 23, 2024

    @nkdengineer
    Contributor

    Proposal

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

    LHN preview for the expense report shows 0.00.
    This issue only happens when there is only one scan expense in the report.

    What is the root cause of that problem?

    When the expense report is a combined report, we filtered out the IOU action of expense report via getCombinedReportActions function here

    if (transactionThreadReportID) {
    const transactionThreadReportActionsArray = Object.values(actions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {});
    sortedReportActions = ReportActionUtils.getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, reportID);
    }

    That makes lastReportAction here null then we fallback to report.lastMessageText which is 0.00 expense in this case

    const lastReportAction = lastVisibleReportActions[reportID] ?? null;

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

    I think we should not filter out the IOU action in OptionsListUtils because we will use this action to get the correct last message text. For example, if the receipt is scanning, LHN should display Receipt scanning... that is the behavior when the expense report is not a combined report.

    Screenshot 2024-08-23 at 12 05 20

    if (transactionThreadReportID) {
    const transactionThreadReportActionsArray = Object.values(actions[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadReportID}`] ?? {});
    sortedReportActions = ReportActionUtils.getCombinedReportActions(sortedReportActions, transactionThreadReportID, transactionThreadReportActionsArray, reportID);
    }

    To do that we can create a new param in getCombinedReportActions like shouldFilterIOUAction with default value is true then if it's false we will return early here

    if (!isMoneyRequestAction(action) || !shouldFilterIOUAction) {
        return true;
    }
    

    What alternative solutions did you explore? (Optional)

    NA

  12. 8 remaining items

  13. francoisl commented on Aug 28, 2024

    @francoisl
    Contributor

    Yeah I would tend to agree too.

    One question about the approach though (and maybe this can be discussed in the PR) is why do we need a new param shouldFilterIOUAction? Or asked differently, when would we use true and when would we use false? If we only set it to false for one-transaction reports, could we count how many items are in filteredParentReportActions instead?
    Basically, I'm thinking if we can avoid introducing a new param, it's one less chance that someone will use it wrong in the future and cause a bug.

  14. removed
    Help WantedApply this label when an issue is open to proposals by contributors
    on Aug 28, 2024
  15. melvin-bot commented on Aug 28, 2024

    @melvin-bot

    📣 @DylanDylann 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

    Offer link
    Upwork job

  16. melvin-bot commented on Aug 28, 2024

    @melvin-bot

    📣 @nkdengineer 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

    Offer link
    Upwork job
    Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
    Keep in mind: Code of Conduct | Contributing 📖

  17. melvin-bot commented on Sep 20, 2024

    @melvin-bot

    This issue has not been updated in over 15 days. @francoisl, @twisterdotcom, @DylanDylann, @nkdengineer 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!

  18. DylanDylann commented on Sep 23, 2024

    @DylanDylann
    Contributor

    @twisterdotcom @francoisl Please help to process payment here

  19. twisterdotcom commented on Sep 23, 2024

    @twisterdotcom
    Contributor

    Payment Summary:

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.ExternalAdded to denote the issue can be worked on by a contributorMonthlyKSv2ReviewingHas a PR in review

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions