Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
6 tasks done
lanitochka17 opened this issue Aug 31, 2023 · 48 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@lanitochka17
Copy link

lanitochka17 commented Aug 31, 2023

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
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 31, 2023
@melvin-bot
Copy link

melvin-bot bot commented Aug 31, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Aug 31, 2023

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

@rayane-djouah
Copy link
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

@rayane-djouah
Copy link
Contributor

rayane-djouah commented Sep 1, 2023

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.

@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Sep 1, 2023
@melvin-bot melvin-bot bot 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 Sep 1, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

Job added to Upwork: https://www.upwork.com/jobs/~016b9e851c8568700f

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 1, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 1, 2023

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

@rayane-djouah
Copy link
Contributor

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

@melvin-bot melvin-bot bot added the Overdue label Sep 3, 2023
@mollfpr
Copy link
Contributor

mollfpr commented Sep 4, 2023

Thanks @rayane-djouah I'll do the review today!

@melvin-bot melvin-bot bot removed the Overdue label Sep 4, 2023
@mollfpr
Copy link
Contributor

mollfpr commented Sep 5, 2023

Sorry for the delay @rayane-djouah

Is there any reason why we remove the listener? Is there any related to the performance improve?

@rayane-djouah
Copy link
Contributor

Thanks for the review, @mollfpr.
The listener was unintentionally removed while resolving merge conflicts in that PR. Moreover, I believe there shouldn't be any performance degradation related to this listener.

@rayane-djouah
Copy link
Contributor

the commit was added after this comment

@mollfpr
Copy link
Contributor

mollfpr commented Sep 5, 2023

Is there any way without the listener?

@rayane-djouah
Copy link
Contributor

rayane-djouah commented Sep 5, 2023

Current implementation:
Subscribing: newActionSubscribers holds subscribers for new actions. Using subscribeToNewActionEvent, components can listen for new actions on a specific report. It also offers a way to unsubscribe.

Notification: With notifyNewAction, when a new action occurs, the relevant subscriber's callback is triggered based on the reportID, giving real-time updates.

// New action subscriber array for report pages
let newActionSubscribers = [];
/**
* Enables the Report actions file to let the ReportActionsView know that a new comment has arrived in realtime for the current report
* Add subscriber for report id
* @param {String} reportID
* @param {Function} callback
* @returns {Function} Remove subscriber for report id
*/
function subscribeToNewActionEvent(reportID, callback) {
newActionSubscribers.push({callback, reportID});
return () => {
newActionSubscribers = _.filter(newActionSubscribers, (subscriber) => subscriber.reportID !== reportID);
};
}
/**
* Notify the ReportActionsView that a new comment has arrived
*
* @param {String} reportID
* @param {Number} accountID
* @param {String} reportActionID
*/
function notifyNewAction(reportID, accountID, reportActionID) {
const actionSubscriber = _.find(newActionSubscribers, (subscriber) => subscriber.reportID === reportID);
if (!actionSubscriber) {
return;
}
const isFromCurrentUser = accountID === currentUserAccountID;
actionSubscriber.callback(isFromCurrentUser, reportActionID);
}

Usage: Report.js and IOU.js use the notifyNewAction to alert of new actions

notifyNewAction(reportID, lastAction.actorAccountID, lastAction.reportActionID);

Report.notifyNewAction(chatReport.reportID, payeeAccountID);

Considering an alternative without the listener would mean a fundamental change in our approach, potentially leading to new regressions. What do you think @mollfpr ?

@rayane-djouah
Copy link
Contributor

rayane-djouah commented Sep 5, 2023

@mollfpr, We could potentially examine the sortedReportActions prop of ReportActionsList as an alternative to the listener. However, subscribing to the event emitted from Report.js ensures that we maintain a single source of truth for the "new action" event. This is preferable to inferring the arrival of a new action solely based on prop changes.
additionally, with the sortedReportActions prop update checking approach, the prop will change if an action have been deleted or edited and trigger the check which is a performance issue.

@mollfpr
Copy link
Contributor

mollfpr commented Sep 6, 2023

@rayane-djouah I try your listener solution, but it's only sometimes working.

Screen.Recording.2023-09-06.at.12.15.17.mov

@rayane-djouah
Copy link
Contributor

@mollfpr I updated my proposal with the correct solution.
As there is the possibility that there are multiple instances of a ReportScreen for the same report, we should allow one subscription to be active, as the subscriptions could otherwise be conflicting, this logic was implemented before that PR here, here, and here.

@rayane-djouah
Copy link
Contributor

video.mp4

@mollfpr
Copy link
Contributor

mollfpr commented Sep 7, 2023

@rayane-djouah I'm okay with the proposal. To make sure, I am asking for clarification in the PR.

@rayane-djouah
Copy link
Contributor

@mollfpr if you get a positive response, let's hold the assignment till the end of the merge freeze 🥶

@rayane-djouah
Copy link
Contributor

@thienlnam could you review the PR when you get a chance? Thank you!

@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

Based on my calculations, the pull request did not get merged within 3 working days of assignment. Please, check out my computations here:

  • when @rayane-djouah got assigned: 2023-09-12 06:08:23 Z
  • when the PR got merged: 2023-09-19 04:34:09 UTC
  • days elapsed: 4

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Sep 22, 2023
@melvin-bot melvin-bot bot changed the title [$500] Report - Conversation history does not scroll down after sending a message and IOU [HOLD for payment 2023-09-29] [$500] Report - Conversation history does not scroll down after sending a message and IOU Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.72-11 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2023-09-29. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

For reference, here are some details about the assignees on this issue:

As a reminder, here are the bonuses/penalties that should be applied for any External issue:

  • Merged PR within 3 business days of assignment - 50% bonus
  • Merged PR more than 9 business days after assignment - 50% penalty

@melvin-bot
Copy link

melvin-bot bot commented Sep 22, 2023

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@mollfpr] The PR that introduced the bug has been identified. Link to the PR:
  • [@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:
  • [@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:
  • [@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.
  • [@sakluger] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Sep 29, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 2, 2023

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

@rayane-djouah
Copy link
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?

@melvin-bot melvin-bot bot removed the Overdue label Oct 2, 2023
@sakluger
Copy link
Contributor

sakluger commented Oct 2, 2023

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

@sakluger
Copy link
Contributor

sakluger commented Oct 2, 2023

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

@sakluger
Copy link
Contributor

sakluger commented Oct 2, 2023

@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!

@mollfpr
Copy link
Contributor

mollfpr commented Oct 3, 2023

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

Completing the checklist now.

@mollfpr
Copy link
Contributor

mollfpr commented Oct 3, 2023

[@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 👎

@sakluger
Copy link
Contributor

sakluger commented Oct 4, 2023

Thanks! Just sent the payment through Upwork @mollfpr.

Regression test steps look good, thanks!

@sakluger sakluger closed this as completed Oct 4, 2023
@izarutskaya
Copy link

Issue reproducible on latest build - v1.3.96-0

Android / native

Screen_Recording_20231107_235340_New.Expensify.mp4

@izarutskaya izarutskaya reopened this Nov 7, 2023
@rayane-djouah
Copy link
Contributor

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

@thienlnam
Copy link
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
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

6 participants