Skip to content

[$250] Expense - Preview in main chat briefly disappears after renaming report and deleting expense #44607

Closed

Description

@izarutskaya

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.0-3.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: https://expensify.testrail.io/index.php?/tests/view/4678766
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Go to staging.new.expensify.com/
  2. Go to workspace chat.
  3. Submit two expenses.
  4. Go to expense report.
  5. Click Title field.
  6. Change the report title and save it.
  7. Submit another expense.
  8. Go to main chat and back to expense report for the rename message to show up.
  9. Go to transaction thread of the latest expense (submitted in Step 7).
  10. Click on the report header > Delete expense.
  11. Delete the expense.

Expected Result:

App will return to expense report because there are still two expenses in the report.

Actual Result:

App returns to main chat, and the expense preview in the main chat disappears briefly.

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

Bug6527060_1719557112849.20240628_143744.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01d610c7726bd86731
  • Upwork Job ID: 1807883887257636893
  • Last Price Increase: 2024-07-08

Activity

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

    @melvin-bot

    Triggered auto assignment to @johncschuster (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. izarutskaya commented on Jun 28, 2024

    @izarutskaya
    Author

    We think this issue might be related to the #collect project.

  4. bernhardoj commented on Jun 28, 2024

    @bernhardoj
    Contributor

    Proposal

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

    Deleting a transaction removes the expense report if the last action in the expense report is renamed action.

    What is the root cause of that problem?

    The expense report will be deleted if the last message text of the expense report is empty.

    App/src/libs/actions/IOU.ts

    Lines 5313 to 5315 in cb8fce8

    const iouReportLastMessageText = ReportActionsUtils.getLastVisibleMessage(iouReport?.reportID ?? '-1', updatedReportAction).lastMessageText;
    const shouldDeleteIOUReport =
    iouReportLastMessageText.length === 0 && !ReportActionsUtils.isDeletedParentAction(lastVisibleAction) && (!transactionThreadID || shouldDeleteTransactionThread);

    We get the last message from the HTML of the message here (getTextFromHtml).

    let messageText = getTextFromHtml(message?.html) ?? '';
    if (messageText) {
    messageText = StringUtils.lineBreaksToSpaces(String(messageText)).substring(0, CONST.REPORT.LAST_MESSAGE_TEXT_MAX_LENGTH).trim();
    }
    return {
    lastMessageText: messageText,
    };

    However, the renamed action doesn't have HTML.
    image

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

    Instead of using getTextFromHtml, we can use getReportActionMessageText.

    let messageText = getReportActionMessageText(lastVisibleAction) ?? '';
    

    getReportActionMessageText will get from the HTML but fallback to text if it doesn't exist.

    function getReportActionMessageText(reportAction: OnyxEntry<ReportAction>): string {
    if (!Array.isArray(reportAction?.message)) {
    return getReportActionText(reportAction);
    }
    // Sometime html can be an empty string
    // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
    return reportAction?.message?.reduce((acc, curr) => `${acc}${getTextFromHtml(curr?.html || curr?.text)}`, '') ?? '';
    }

    So the iou report last message won't be empty and the expense report won't be deleted.

  5. melvin-bot commented on Jul 1, 2024

    @melvin-bot

    @johncschuster Whoops! This issue is 2 days overdue. Let's get this updated quick!

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 1, 2024
  7. changed the title [-]Expense - Preview in main chat briefly disappears after renaming report and deleting expense[/-] [+][$250] Expense - Preview in main chat briefly disappears after renaming report and deleting expense[/+] on Jul 1, 2024
  8. melvin-bot commented on Jul 1, 2024

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

    @melvin-bot

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

  11. 22 remaining items

  12. melvin-bot commented on Aug 21, 2024

    @melvin-bot

    This issue has not been updated in over 15 days. @tylerkaraszewski, @johncschuster, @sobitneupane, @bernhardoj 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!

  13. sobitneupane commented on Aug 22, 2024

    @sobitneupane
    Contributor

    @johncschuster This is ready for payment. PR was developed a month back. #45365 (comment)

  14. sobitneupane commented on Sep 2, 2024

    @sobitneupane
    Contributor
  15. bernhardoj commented on Sep 4, 2024

    @bernhardoj
    Contributor

    Payment pending. Requested in ND.

  16. johncschuster commented on Sep 9, 2024

    @johncschuster
    Contributor

    Sorry for the delay! Working on this now.

  17. johncschuster commented on Sep 9, 2024

    @johncschuster
    Contributor

    Payment Summary:

    Contributor: @bernhardoj owed $250 via NewDot
    Contributor+: @sobitneupane owed $250 via NewDot

  18. JmillsExpensify commented on Sep 9, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  19. johncschuster commented on Sep 10, 2024

    @johncschuster
    Contributor

    @sobitneupane, do we need any regression test steps? If so, can you provide them?

  20. sobitneupane commented on Sep 12, 2024

    @sobitneupane
    Contributor

    Regression Test Proposal

    1. Open a workspace chat
    2. Submit 2 money requests
    3. Rename the expense report title
    4. Reopen/refresh the expense report to see the renamed system message
    5. Add another money request
    6. Delete the recently added money request
    7. Verify the expense report isn't deleted and you stay at the expense report page

    Do we agree 👍 or 👎

  21. johncschuster commented on Sep 20, 2024

    @johncschuster
    Contributor

    Thanks, @sobitneupane! Please request payment!

  22. garrettmknight commented on Oct 23, 2024

    @garrettmknight
    Contributor

    $250 approved for @sobitneupane

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