Skip to content

[HOLD for payment 2023-09-29] [$500] Report - Conversation history does not scroll down after sending a message and IOU #26432

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

Preconditions:
Log in using a HIGH traffic account.

  1. Open New Expensify app
  2. Navigate to a chat that has a very long history
  3. Scroll up the conversation history
  4. Send any message or IOU

Expected Result:

When you send a message or IOU in a conversation, the message history should scroll down without artifacts to the newly sent message or IOU

Actual Result:

When sending a message or IOU in a conversation, the message history doesn't scroll down, and on Native apps the conversation history starts scrolling chaotically up to down

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.60-1

Reproducible in staging?: Yes

Reproducible in production?: Yes

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

Notes/Photos/Videos: Any additional supporting documentation

Bug6184276_Recording_KI_22367_Android.mp4

Expensify/Expensify Issue URL:

Issue reported by: @rayane-djouah

Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1692633002201879

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~016b9e851c8568700f
  • Upwork Job ID: 1697745435700506624
  • Last Price Increase: 2023-09-08
  • Automatic offers:
    • mollfpr | Reviewer | 26624598
    • rayane-djouah | Contributor | 26624600
    • rayane-djouah | Reporter | 26624601

Activity

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

    @melvin-bot

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

  3. melvin-bot commented on Aug 31, 2023

    @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
  4. rayane-d commented on Aug 31, 2023

    @rayane-d
    Contributor

    @lanitochka17, I reported the same bug 10 days ago. You can find the details here: https://expensify.slack.com/archives/C049HHMV9SM/p1692633002201879. could you credit my name when addressing this? Thank you

  5. rayane-d commented on Sep 1, 2023

    @rayane-d
    Contributor

    Proposal

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

    When a new message is sent by the current user, the app does not automatically scroll to the bottom.

    What is the root cause of that problem?

    The bug was introduced by this PR #18637. In this PR, this scrolling logic was removed from the ReportActionsView component while migrating the Unread Marker logic from ReportActionsView to ReportActionsList component.

    The behavior before this PR was:

    in the previous commit (before that PR), If a new message is sent and it's from the current user the app scroll to the bottom:

    const unsubscribe = Report.subscribeToNewActionEvent(reportID, (isFromCurrentUser, newActionID) => {
    const isNewMarkerReportActionIDSet = !_.isEmpty(newMarkerReportActionIDRef.current);
    // If a new comment is added and it's from the current user scroll to the bottom otherwise leave the user positioned where
    // they are now in the list.
    if (isFromCurrentUser) {
    scrollToBottom();

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

    Integrate the subscribeToNewActionEvent call within the ReportActionsList component, coinciding with the migrated unread marker logic:

    // In the component we are subscribing to the arrival of new actions.
    // As there is the possibility that there are multiple instances of a ReportScreen
    // for the same report, we only ever want one subscription to be active, as
    // the subscriptions could otherwise be conflicting.
    const newActionUnsubscribeMap = {};
    useEffect(() => {
    
        // Why are we doing this, when in the cleanup of the useEffect we are already calling the unsubscribe function?
        // Answer: On web, when navigating to another report screen, the previous report screen doesn't get unmounted,
        //         meaning that the cleanup might not get called. When we then open a report we had open already previosuly, a new
        //         ReportScreen will get created. Thus, we have to cancel the earlier subscription of the previous screen,
        //         because the two subscriptions could conflict!
        //         In case we return to the previous screen (e.g. by web back navigation) the useEffect for that screen would
        //         fire again, as the focus has changed and will set up the subscription correctly again.
        const previousSubUnsubscribe = newActionUnsubscribeMap[report.reportID];
        if (previousSubUnsubscribe) {
            previousSubUnsubscribe();
        }
    
        // This callback is triggered when a new action arrives via Pusher and the event is emitted from Report.js. This allows us to maintain
        // a single source of truth for the "new action" event instead of trying to derive that a new action has appeared from looking at props.
        const unsubscribe = Report.subscribeToNewActionEvent(report.reportID, (isFromCurrentUser) => {
            // If a new comment is added and it's from the current user scroll to the bottom otherwise leave the user positioned where
            // they are now in the list.
            if (!isFromCurrentUser)
                return;
            reportScrollManager.scrollToBottom();
        });
        const cleanup = () => {
            if (unsubscribe) {
                unsubscribe();
            }
            Report.unsubscribeFromReportChannel(report.reportID);
        };
    
        newActionUnsubscribeMap[report.reportID] = cleanup;
    
        return () => {
            cleanup();
        };
    }, [report.reportID, reportScrollManager]);

    Result:

    31.New.Expensify.Mozilla.Firefox.2023-09-01.01-39-29.mp4

    What alternative solutions did you explore? (Optional)

    Alternative 1:

    Reintegrate the subscribeToNewActionEvent call within the ReportActionsView component:

    import useReportScrollManager from '../../../hooks/useReportScrollManager';
    const reportScrollManager = useReportScrollManager();
    // In the component we are subscribing to the arrival of new actions.
    // As there is the possibility that there are multiple instances of a ReportScreen
    // for the same report, we only ever want one subscription to be active, as
    // the subscriptions could otherwise be conflicting.
    const newActionUnsubscribeMap = {};
    useEffect(() => {
    
        // Why are we doing this, when in the cleanup of the useEffect we are already calling the unsubscribe function?
        // Answer: On web, when navigating to another report screen, the previous report screen doesn't get unmounted,
        //         meaning that the cleanup might not get called. When we then open a report we had open already previosuly, a new
        //         ReportScreen will get created. Thus, we have to cancel the earlier subscription of the previous screen,
        //         because the two subscriptions could conflict!
        //         In case we return to the previous screen (e.g. by web back navigation) the useEffect for that screen would
        //         fire again, as the focus has changed and will set up the subscription correctly again.
        const previousSubUnsubscribe = newActionUnsubscribeMap[reportID];
        if (previousSubUnsubscribe) {
            previousSubUnsubscribe();
        }
    
        // This callback is triggered when a new action arrives via Pusher and the event is emitted from Report.js. This allows us to maintain
        // a single source of truth for the "new action" event instead of trying to derive that a new action has appeared from looking at props.
        const unsubscribe = Report.subscribeToNewActionEvent(reportID, (isFromCurrentUser) => {
            // If a new comment is added and it's from the current user scroll to the bottom otherwise leave the user positioned where
            // they are now in the list.
            if (!isFromCurrentUser)
                return;
            reportScrollManager.scrollToBottom();
        });
        const cleanup = () => {
            if (unsubscribe) {
                unsubscribe();
            }
            Report.unsubscribeFromReportChannel(reportID);
        };
    
        newActionUnsubscribeMap[reportID] = cleanup;
    
        return () => {
            cleanup();
        };
    }, [reportID, reportScrollManager]);

    Alternative 2:

    We could potentially examine the sortedReportActions prop of ReportActionsList inferring the arrival of a new action solely based on prop changes as an alternative to the listener.

  6. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 1, 2023
  7. changed the title [-] Report - Conversation history does not scroll down after sending a message and IOU[/-] [+][$500] Report - Conversation history does not scroll down after sending a message and IOU[/+] on Sep 1, 2023
  8. melvin-bot commented on Sep 1, 2023

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

    @melvin-bot

    Current assignee @sakluger is eligible for the External assigner, not assigning anyone new.

  11. melvin-bot commented on Sep 1, 2023

    @melvin-bot

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

  12. rayane-d commented on Sep 3, 2023

    @rayane-d
    Contributor

    @mollfpr, could you please review my proposal when you get a chance? Thank you!

  13. 47 remaining items

  14. melvin-bot commented on Oct 2, 2023

    @melvin-bot

    @sakluger, @mollfpr, @thienlnam, @rayane-djouah Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  15. rayane-d commented on Oct 2, 2023

    @rayane-d
    Contributor

    the PR was approved by C+ within 2 days of assignment, and it was waiting for only the Engineer's approval & merge (+2 days after C+ approved), and in this stage it exceeds the 3 days rule, and the engineer had no major requested changes to the PR once they reviewed. is this issue eligible for urgency bonus?

  16. sakluger commented on Oct 2, 2023

    @sakluger
    Contributor

    Yes, I reviewed the PR timeline and this one qualifies for the efficiency bonus. I'm going through and writing up payments now.

  17. sakluger commented on Oct 2, 2023

    @sakluger
    Contributor

    Summarizing payouts for this issue:

    Bug reporter: @rayane-djouah $50 (paid via Upwork)
    Contributor: @rayane-djouah $750 (paid via Upwork)
    Contributor+: @mollfpr $750 (need to confirm preferred payment method)

    Above payments include efficiency bonus 🎉
    Upwork job: https://www.upwork.com/jobs/~016b9e851c8568700f

  18. sakluger commented on Oct 2, 2023

    @sakluger
    Contributor

    @mollfpr can you please confirm if you'd prefer to be paid via Upwork or NewDot? You've already accepted the Upwork contract, so if you'd like to be paid via NewDot I'd have to cancel that.

    Also, can you please complete the BZ checklist? Thanks!

  19. mollfpr commented on Oct 3, 2023

    @mollfpr
    Contributor

    @sakluger I think from Upwork is okay since we already have the contract.

    Completing the checklist now.

  20. mollfpr commented on Oct 3, 2023

    @mollfpr
    Contributor

    [@mollfpr] The PR that introduced the bug has been identified. Link to the PR:

    #18637

    [@mollfpr] 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/18637/files#r1318079323

    [@mollfpr] A discussion in #expensify-bugs 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:

    I don't think we can have a checklist to prevent this. The regression step should be good.

    [@mollfpr] Determine if we should create a regression test for this bug.
    [@mollfpr] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

    1. Open the app
    2. Navigate to a chat that has a long history
    3. Scroll up the conversation history
    4. Send any message or IOU
    5. Verify that the conversation history automatically scrolls down to the new message.
    6. 👍 or 👎
  21. sakluger commented on Oct 4, 2023

    @sakluger
    Contributor

    Thanks! Just sent the payment through Upwork @mollfpr.

    Regression test steps look good, thanks!

  22. izarutskaya commented on Nov 7, 2023

    @izarutskaya

    Issue reproducible on latest build - v1.3.96-0

    Android / native

    Screen_Recording_20231107_235340_New.Expensify.mp4
  23. rayane-d commented on Nov 7, 2023

    @rayane-d
    Contributor

    @izarutskaya I think we should create a new issue for this instead of reopening this issue

  24. thienlnam commented on Nov 8, 2023

    @thienlnam
    Contributor

    We're handling in here #30947

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething 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