Skip to content

[Awaiting checklist] [$250] mWeb - Chat - Chat not autoscrolled when categorized expense is sent to chat with content. #54001

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: 9.0.75-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: #52221
Email or phone of affected tester (no customers): ibellicotest+91@gmail.com
Issue reported by: Applause Internal Team
Device used: Motorola MotoG60 - Android 12
App Component: Money Requests

Action Performed:

Precondition: Workspace to submit categorized expense, must have an expense on it.

  1. Open the staging.new.expensify.com
  2. Open self DM and tap on the "+" button
  3. Select "Track Expense" and complete the creation flow.
  4. Once naviagted to chat again, tap on "Categorize it"
  5. Select any category.
  6. Add a merchant.
  7. Submit the expense to a workspace that already has an expense or content on it.

Expected Result:

When categorizing an expense and submitting it to a workspace that already has content in it, the chat should be autoscrolled.

Actual Result:

Chat is not autoscrolled after categorizing an expense and submitting it to a workspace chat that already has an expense or content in it.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6691800_1733981730882.Categorize.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021867328605330762929
  • Upwork Job ID: 1867328605330762929
  • Last Price Increase: 2025-01-02
  • Automatic offers:
    • shubham1206agra | Reviewer | 105580363
Issue OwnerCurrent Issue Owner: @shubham1206agra

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 12, 2024
  2. melvin-bot commented on Dec 12, 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. bernhardoj commented on Dec 12, 2024

    @bernhardoj
    Contributor

    Proposal

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

    The categorized track expense isn't shown fully because the chat isn't auto scrolled to the bottom.

    What is the root cause of that problem?

    This only happens with WS track expense. This issue happens when the report last action created value doesn't match the report lastVisibleActionCreated.

    const hasNewestReportAction =
    visibleReportActions.at(0)?.created === report.lastVisibleActionCreated || visibleReportActions.at(0)?.created === transactionThreadReport?.lastVisibleActionCreated;

    const shouldEnableAutoScroll = (hasNewestReportAction && (!reportActionID || !isNavigatingToLinkedMessage)) || (transactionThreadReport && !prevTransactionThreadReport);

    When we create a track expense, including categorizing it, we don't update the lastVisibleActionCreated at all.

    App/src/libs/actions/IOU.ts

    Lines 1507 to 1514 in 50c1db8

    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`,
    value: {
    ...chatReport,
    lastMessageText: ReportActionsUtils.getReportActionText(iouAction),
    lastMessageHtml: ReportActionsUtils.getReportActionHtml(iouAction),
    lastReadTime: DateUtils.getDBTime(),
    iouReportID: iouReport?.reportID,

    This doesn't happen to, money requests, for example. If we see here, we don't set the lastVisibleActionCreated too for the money request.

    App/src/libs/actions/IOU.ts

    Lines 696 to 702 in 50c1db8

    value: {
    ...chat.report,
    lastReadTime: DateUtils.getDBTime(),
    lastMessageTranslationKey: '',
    iouReportID: iou.report.reportID,
    ...outstandingChildRequest,
    ...(isNewChatReport ? {pendingFields: {createChat: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}} : {}),

    But we actually mutate the chat report lastVisibleActionCreated here when a new report preview is created.

    App/src/libs/actions/IOU.ts

    Lines 2339 to 2343 in 50c1db8

    if (reportPreviewAction) {
    reportPreviewAction = ReportUtils.updateReportPreview(iouReport, reportPreviewAction, false, comment, optimisticTransaction);
    } else {
    reportPreviewAction = ReportUtils.buildOptimisticReportPreview(chatReport, iouReport, comment, optimisticTransaction);
    chatReport.lastVisibleActionCreated = reportPreviewAction.created;

    Also, if we do a track expense directly on the WS (without going through Categorize flow), then it works fine even though we don't update the lastVisibleActionCreated. That's because we trigger notifyNewAction which will scroll the chat to the bottom.

    Report.notifyNewAction(activeReportID ?? '', payeeAccountID);

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

    I don't like mutating the object and instead of using notifyNewAction, it's better to fix the root cause of the lastVisibleActionCreated optimistic data. So, to fix this, we can update the lastVisibleActionCreated to the report preview action if we are creating a new report preview.

    App/src/libs/actions/IOU.ts

    Lines 1515 to 1523 in 8ed48d2

    onyxMethod: Onyx.METHOD.MERGE,
    key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`,
    value: {
    ...chatReport,
    lastMessageText: ReportActionsUtils.getReportActionText(iouAction),
    lastMessageHtml: ReportActionsUtils.getReportActionHtml(iouAction),
    lastReadTime: DateUtils.getDBTime(),
    iouReportID: iouReport?.reportID,
    },

    ...(shouldCreateNewMoneyRequestReport && {lastVisibleActionCreated: reportPreviewAction?.created}),
    

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    We can create a test for buildOnyxDataForTrackExpense and test the optimistic data of the chat report when shouldCreateNewMoneyRequestReport is true and false.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Dec 12, 2024
  5. changed the title [-]mWeb - Chat - Chat not autoscrolled when categorized expense is sent to chat with content.[/-] [+][$250] mWeb - Chat - Chat not autoscrolled when categorized expense is sent to chat with content.[/+] on Dec 12, 2024
  6. melvin-bot commented on Dec 12, 2024

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 12, 2024
  8. melvin-bot commented on Dec 12, 2024

    @melvin-bot

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

  9. melvin-bot commented on Dec 16, 2024

    @melvin-bot

    @twisterdotcom, @shubham1206agra Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  10. twisterdotcom commented on Dec 18, 2024

    @twisterdotcom
    Contributor

    Still Help Wanted

  11. melvin-bot commented on Dec 18, 2024

    @melvin-bot

    @twisterdotcom, @shubham1206agra Eep! 4 days overdue now. Issues have feelings too...

  12. 42 remaining items

  13. twisterdotcom commented on Feb 18, 2025

    @twisterdotcom
    Contributor

    Payment Summary:

  14. changed the title [-][Due for payment 2025-02-18] [$250] mWeb - Chat - Chat not autoscrolled when categorized expense is sent to chat with content.[/-] [+][Awaiting checklist] [$250] mWeb - Chat - Chat not autoscrolled when categorized expense is sent to chat with content.[/+] on Feb 18, 2025
  15. bernhardoj commented on Feb 18, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  16. JmillsExpensify commented on Feb 19, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  17. melvin-bot commented on Feb 21, 2025

    @melvin-bot

    @twisterdotcom, @srikarparsi, @bernhardoj, @shubham1206agra Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  18. shubham1206agra commented on Feb 22, 2025

    @shubham1206agra
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/36934/files#r1966458419

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: Not Required

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/473689

    Regression Test Proposal

    Test:

    1. Open a workspace chat with no unsettled expenses
    2. Split bill on the workspace
    3. Verify the chat is scrolled to the bottom

    Do we agree 👍 or 👎

  19. twisterdotcom commented on Feb 24, 2025

    @twisterdotcom
    Contributor

    Please accept the Upwork offer now @shubham1206agra.

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions