Skip to content

Chat does not scroll to the bottom when submitting expenses while being at the top of the chat #55693

Closed

Description

@mitarachim

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.89-2
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5508042
Email or phone of affected tester (no customers): applausetester+100106kh@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Mac 15.0 / Chrome
App Component: Chat Report View

Action Performed:

  1. Go to staging.new.expensify.com
  2. Open DM with any user.
  3. Send about 50 messages so that the chat is scrollable.
  4. Scroll to the top.
  5. Submit an expense to the user.
  6. Note that the chat scrolls to the bottom.
  7. Scroll to the top again.
  8. Submit another expense.

Expected Result:

Chat will scroll to the bottom every time user submits an expense while being at the top of the chat (production behavior).

Actual Result:

Chat only scrolls to the bottom when user submits the first expense. It no longer scrolls down when submitting more expenses while at the top of the chat.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6722304_1737676927307.20250124_075208.mp4

View all open jobs on GitHub

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerCashThis issue or pull request should block deployment
    on Jan 24, 2025
  2. melvin-bot commented on Jan 24, 2025

    @melvin-bot

    Triggered auto assignment to @rlinoz (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  3. melvin-bot commented on Jan 24, 2025

    @melvin-bot

    Triggered auto assignment to @sakluger (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.

  4. melvin-bot commented on Jan 24, 2025

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on Jan 24, 2025

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. samranahm commented on Jan 24, 2025

    @samranahm
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-01-24 15:20:14 UTC.

    Proposal

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

    Chat does not scroll to the bottom when submitting expenses while being at the top of the chat

    What is the root cause of that problem?

    when user create an expense this useEffect trigger

    useEffect(() => {
    if (!pendingBottomScroll || scrollingVerticalOffset.current === 0) {
    return;
    }
    if (isNewMessageDisplayed) {
    InteractionManager.runAfterInteractions(() => {
    setIsFloatingMessageCounterVisible(false);
    reportScrollManager.scrollToBottom();
    setPendingBottomScroll(false);
    });
    }
    }, [pendingBottomScroll, reportScrollManager, isNewMessageDisplayed]);

    Here one of the dependency isNewMessageDisplayed check if the

    lastAction?.reportActionID !== lastPrevVisibleAction?.reportActionID

    that return true on first expense and useEffect condition

    if (isNewMessageDisplayed) {

    pass and it take us to bottom of the screen

    but when we submit another expense both lastAction?.reportActionID and lastPrevVisibleAction?.reportActionID remain same that don't trigger the useEffect, and because isNewMessageDisplayed if false so it does't scroll to bottom.

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

    In isNewMessageDisplayed we should define a new const

     const isMultipleChildMoneyRequests = (lastAction?.childMoneyRequestCount ?? 0) > 1;

    this will check if we have more than 1 childMoneyRequest and return true

    const isNewMessageDisplayed = useMemo(() => {
            const prevActions = Object.values(prevSortedVisibleReportActionsObjects);
            const lastPrevVisibleAction = prevActions.at(0);
            const isMultipleChildMoneyRequests = (lastAction?.childMoneyRequestCount ?? 0) > 1;
            return lastAction?.reportActionID !== lastPrevVisibleAction?.reportActionID || isMultipleChildMoneyRequests;
    }, [prevSortedVisibleReportActionsObjects, lastAction]);

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

    N/A

    What alternative solutions did you explore? (Optional)


    POC

    Screen.Recording.2025-01-24.at.8.12.51.PM.mov
  7. rlinoz commented on Jan 24, 2025

    @rlinoz
    Contributor

    But I mean, shouldn't lastAction?.reportActionID get updated?

    Also, it looks related to this PR as was pointed out in the slack thread #54071

  8. 4 remaining items

  9. rlinoz commented on Jan 24, 2025

    @rlinoz
    Contributor

    But I mean, shouldn't lastAction?.reportActionID get updated?

    Oh it shouldn't because it is the same reportpreview 🤦‍♂

  10. samranahm commented on Jan 24, 2025

    @samranahm
    Contributor

    But I mean, shouldn't lastAction?.reportActionID get updated?

    Oh it shouldn't because it is the same reportpreview 🤦‍♂

    Exactly

  11. samranahm commented on Jan 24, 2025

    @samranahm
    Contributor
  12. mountiny commented on Jan 27, 2025

    @mountiny
    Contributor

    I think since we are now closer to the deployment, this seems like an edge case flow, and it might have been fixed as well with the linked CP @samranahm. Are you still able to reproduce it?

    Going to demote this now

  13. samranahm commented on Jan 27, 2025

    @samranahm
    Contributor

    @mountiny Issue is clearly reproducible and my updated proposal is gently fixing it

  14. rlinoz commented on Jan 27, 2025

    @rlinoz
    Contributor

    @samranahm your proposal doesn't address the case where the report may not be the last action, but we still should scroll to the bottom of the chat.

    1. Send enough messages to have a scroll
    2. Scroll up and send a money request, verify you are scrolled to the bottom
    3. Send another text message
    4. Scroll up and send a new money request, you should also be scrolled to the bottom
  15. mountiny commented on Jan 27, 2025

    @mountiny
    Contributor

    @samranahm Will your proposal fix this blocker too? #55780

  16. samranahm commented on Jan 27, 2025

    @samranahm
    Contributor

    @mountiny already on it, will update here really soon

  17. melvin-bot commented on Jan 27, 2025

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  18. samranahm commented on Jan 27, 2025

    @samranahm
    Contributor

    @samranahm your proposal doesn't address the case where the report may not be the last action, but we still should scroll to the bottom of the chat.

    1. Send enough messages to have a scroll
    2. Scroll up and send a money request, verify you are scrolled to the bottom
    3. Send another text message
    4. Scroll up and send a new money request, you should also be scrolled to the bottom

    @rlinoz, this issue should be addressed by handle like this. Please take a look.

    const reportPreviewActions = sortedReportActions?.map(action => {
            if (action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) {
                return action;
            }
    }).filter(action => action !== undefined);
            
    const isMultipleChildMoneyRequests = (reportPreviewActions?.at(0)?.childMoneyRequestCount ?? 0) > 1 && reportPreviewActions?.at(0)?.childStatusNum === 1;
  19. mountiny commented on Jan 27, 2025

    @mountiny
    Contributor

    Did the revert from Amy fix this?

  20. samranahm commented on Jan 27, 2025

    @samranahm
    Contributor

    @mountiny Yes, this issue no more reproducible after the revert #54071

  21. rlinoz commented on Jan 28, 2025

    @rlinoz
    Contributor

    Yeah, that was the original PR, closing this one then

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.EngineeringReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions