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-06-28] [$1000] mweb - Chat - Reaction list does not appear after navigating to chat from member detail #20513

Closed
1 of 6 tasks
kbecciv opened this issue Jun 9, 2023 · 28 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 Reviewing Has a PR in review

Comments

@kbecciv
Copy link

kbecciv commented Jun 9, 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!


Issue found when executing PR #19612

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Go to any group chat with reactions to messages.
  3. Long press on the reaction.
  4. Tap on the group chat header.
  5. Tap on any member > Message member.
  6. Return to group chat in Step 2.
  7. Long press on the reaction.

Expected Result:

Reaction list shows up.

Actual Result:

Reaction list does not show up.

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.26.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

Bug6086568_Screen_Recording_20230609_193946_Chrome.mp4

Expensify/Expensify Issue URL:

Issue reported by: Applause - Internal Team

Slack conversation:

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0162c97fe6a772efa5
  • Upwork Job ID: 1667199561562185728
  • Last Price Increase: 2023-06-09
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 9, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 9, 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

@slafortune slafortune added the External Added to denote the issue can be worked on by a contributor label Jun 9, 2023
@melvin-bot melvin-bot bot changed the title mweb - Chat - Reaction list does not appear after navigating to chat from member detail [$1000] mweb - Chat - Reaction list does not appear after navigating to chat from member detail Jun 9, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 9, 2023

Job added to Upwork: https://www.upwork.com/jobs/~0162c97fe6a772efa5

@melvin-bot
Copy link

melvin-bot bot commented Jun 9, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 9, 2023

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

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

melvin-bot bot commented Jun 9, 2023

Triggered auto assignment to @francoisl (External), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@maxim-abuzarov
Copy link

Proposal

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

Reaction list does not appear after navigating to chat from member detail

What is the root cause of that problem?

After re-render we have null instead of ref and get in this part of logic:

if (!reactionListRef.current) {
return;
}

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

  1. add in constructor
    this.ref = ReactionList.reactionListRef;
    this.setTextInputRef = this.setTextInputRef.bind(this);

    constructor(props) {
    super(props);
    this.didLayout = false;
    this.didSubscribeToReportTypingEvents = false;
    this.unsubscribeVisibilityListener = null;
    this.hasCachedActions = _.size(props.reportActions) > 0;

  2. add in shoudComponentUpdate
    if (ReactionList.reactionListRef !== this.ref) {return true}

    shouldComponentUpdate(nextProps, nextState) {
    if (!_.isEqual(nextProps.reportActions, this.props.reportActions)) {
    this.mostRecentIOUReportActionID = ReportActionsUtils.getMostRecentIOURequestActionID(nextProps.reportActions);
    return true;
    }

  3. add function in ReportActionsView class component
    setTextInputRef(el) { ReactionList.reactionListRef.current = el; this.ref = el }

  4. change this

    ref={ReactionList.reactionListRef}

    to this:
    ref={(ref) => ref === null ? this.ref : this.setTextInputRef(ref)}

What alternative solutions did you explore? (Optional)


@jeet-dhandha
Copy link
Contributor

jeet-dhandha commented Jun 9, 2023

Proposal

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

  • The emoji picker stops working when you switch from a group chat to a member's chat using the group's details page, and then return to the group chat.

What is the root cause of that problem?

Here we have two issues:

  • When ReportScreen unmounts the ref for the EmojiPicker is set to null, and when the ReportScreen is re-rendered the ref is not updated. This causes the EmojiPicker to not be able to be used.
  • When ReportActionsView unmounts the ref for the PopoverReactionList is set to null, and when the ReportActionsView is re-rendered the ref is not updated. This causes the PopoverReactionList to not be able to be used.

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

To resolve these two issue we need to do the following:

  • Adding a way to update the ref for the EmojiPicker when the ReportScreen is re-rendered.
class ReportScreen extends React.Component {
  constructor(props) {
      ... rest code
      this.updateEmojiPickerRef = this.updateEmojiPickerRef.bind(this);
      ... rest code
      this.emojiPickerRef = React.createRef();
  }

  /**
  * Function - Resets Ref for Emoji Picker
  * @explanation :
  * When the component unmounts the ref sets to null for the Emoji Picker,
  * this function resets the ref to the current Emoji Picker's Ref.
  */ 
  updateEmojiPickerRef() {
      if(!this.emojiPickerRef.current || EmojiPickerAction.emojiPickerRef.current ) { return; }
      EmojiPickerAction.emojiPickerRef.current = this.emojiPickerRef.current;
  }

  ... rest functions

  render() {
    ... rest code 
    
    // Function will update the ref if not already set (when the component is re-rendered)
    this.updateEmojiPickerRef()

    return (
      ... rest code 
      // Updated ref will be passed to the EmojiPicker component
      <EmojiPicker ref={this.emojiPickerRef} />
      ... rest code 
    )
  }
}
  • Adding a way to update the ref for the PopoverReactionList when the ReportActionsView is re-rendered.
class ReportActionsView extends React.Component {
  constructor(props) {
      ... rest code
      this.updatePopoverReactionListRef = this.updatePopoverReactionListRef.bind(this);
      this.popoverReactionListRef = React.createRef();
  }

  ... rest functions

  /**
  * Function - Resets Ref for PopoverReactionList
  * @explanation :
  * When the component unmounts the ref sets to null for the PopoverReactionList,
  * this function resets the ref to the current PopoverReactionList's Ref.
  */ 
  updatePopoverReactionListRef() {
    if(!this.popoverReactionListRef.current || ReactionList.reactionListRef.current) { return; }
    ReactionList.reactionListRef.current = this.popoverReactionListRef.current;
  }

  render() {
    ... rest code 
    
    // Function will update the ref if not already set (when the component is re-rendered)
    this.updatePopoverReactionListRef()

    return (
      ... rest code 
      // Updated ref will be passed to the EmojiPicker component
      <PopoverReactionList
        ref={ReactionList.reactionListRef}
        ref={this.popoverReactionListRef}
        reportID={this.props.report.reportID}
      />
      ... rest code 
    )
  }
}

Before Fix:

Screen.Recording.2023-06-10.at.2.23.44.AM.mov

After Fix:

Screen.Recording.2023-06-10.at.2.22.53.AM.mov

Thank You,
Jeet Dhandha.

@bernhardoj
Copy link
Contributor

Proposal

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

Reaction list modal does not show up anymore after going to another chat from participants list and go back to current chat.

What is the root cause of that problem?

When we long press the reaction, it will call ReactionList.showReactionList.

const onReactionListOpen = (event) => {
ReactionList.showReactionList(event, popoverReactionListAnchor.current, reaction.emoji, props.reportActionID);
};

As the others explained, the reactionListRef.current is null after went back from other user chat.

function showReactionList(event, reactionListPopoverAnchor, emojiName, reportActionID) {
if (!reactionListRef.current) {
return;
}
reactionListRef.current.showReactionList(event, reactionListPopoverAnchor, emojiName, reportActionID);
}

The ref we have (reactionListRef) currently is global and being set here.

<PopoverReactionList
ref={ReactionList.reactionListRef}

If ReportActionsView unmounts, reactionListRef will become null. So, in this issue case:

  1. Open a group chat, ReportActionsView is mounted and reactionListRef is set.
  2. Open participants list and start a chat with different member of the group.
  3. Once again, ReportActionsView is mounted and reactionListRef is set.
  4. When we go back, ReportActionsView is unmounted and reactionListRef is now null

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

We should replace the global ref with just a local ref.

  1. Remove ReactionList.js (this is the file that store the global ref).
  2. Create a new local ref in ReportActionsView called reactionListRef and pass it to PopoverReactionList ref.
    <PopoverReactionList
    ref={ReactionList.reactionListRef}
  3. To pass the ref deep down to ReportActionItemReactions, we can use react context. We can name it ReactionListRefContext. Then, use the provider to provide the value by wrapping ReportActionsList.
<ReactionListRefContext.Provider value={this.reactionListRef}>

<ReportActionsList
report={this.props.report}

4. In ReportActionItemReactions, receive the context with useContext.
const reactionListRef = useContext(ReactionListRefContext);
5. We can use this new ref now to open the reaction list
reactionListRef.current.showReactionList
const onReactionListOpen = (event) => {
ReactionList.showReactionList(event, popoverReactionListAnchor.current, reaction.emoji, props.reportActionID);
};

@melvin-bot melvin-bot bot added the Overdue label Jun 12, 2023
@thesahindia
Copy link
Member

I think I prefer @bernhardoj's proposal.

C+ reviewed 🎀👀🎀

cc: @francoisl

@melvin-bot melvin-bot bot removed the Overdue label Jun 12, 2023
@francoisl
Copy link
Contributor

👍 yeah I like the idea of making the ref local instead, let's go with that proposal.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 13, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 13, 2023

📣 @bernhardoj You have been assigned to this job by @francoisl!
Please apply to this job in Upwork and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@bernhardoj
Copy link
Contributor

PR is ready for review.

@melvin-bot
Copy link

melvin-bot bot commented Jun 15, 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 @bernhardoj got assigned: 2023-06-13 18:43:18 Z
  • when the PR got merged: 2023-06-15 23:11:06 UTC
  • days elapsed: 3

On to the next one 🚀

@bernhardoj
Copy link
Contributor

I think it's still within 3 days, right?

@slafortune
Copy link
Contributor

@bernhardoj - yep, I think Melvin messed up math there!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Jun 21, 2023
@melvin-bot melvin-bot bot changed the title [$1000] mweb - Chat - Reaction list does not appear after navigating to chat from member detail [HOLD for payment 2023-06-28] [$1000] mweb - Chat - Reaction list does not appear after navigating to chat from member detail Jun 21, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jun 21, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Jun 21, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.29-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-06-28. 🎊

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

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 Jun 21, 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:

  • [@thesahindia] The PR that introduced the bug has been identified. Link to the PR:
  • [@thesahindia] 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:
  • [@thesahindia] 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:
  • [@thesahindia] Determine if we should create a regression test for this bug.
  • [@thesahindia] 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.
  • [@slafortune] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Daily KSv2 and removed Weekly KSv2 labels Jun 21, 2023
@melvin-bot
Copy link

melvin-bot bot commented Jul 4, 2023

@francoisl, @slafortune, @bernhardoj, @thesahindia Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@slafortune
Copy link
Contributor

@bernhardoj @thesahindia offers sent!

@thesahindia can you please complete the checklist?

@thesahindia
Copy link
Member

@thesahindia can you please complete the checklist?

We can skip it. We shouldn't call it a regression. It was an edge case that we couldn't have thought about.

If we want we can add a test case for this. Steps -

  1. Open a group chat or create one if you don't have
  2. Add an emoji reaction to a chat message
  3. In Web/Desktop, right click the reaction. In Android/iOS/mWeb, long press the reaction
  4. Verify a reaction list is displayed
  5. Close the reaction list
  6. Open the group participants
  7. Select any participant
  8. Press/click "Message {participant name}"
  9. Verify you are navigated to the chat page with the user you selected
  10. Go back to the previous chat
  11. Repeat step 3-4

@thesahindia
Copy link
Member

@slafortune, I am going to request money on new dot, so no need to pay me on Upwork.

@slafortune
Copy link
Contributor

@JmillsExpensify
Copy link

@slafortune Can you please leave a payment summary for this issue so that I can issue payment via NewDot?

@thesahindia
Copy link
Member

@bernhardoj - yep, I think Melvin messed up math there!

Hey @slafortune can you please confirm the C+ compensation on this issue? I believe it was $1500 since it was eligible for the speed bonus.

@slafortune
Copy link
Contributor

Oh yes, you are correct - and Melvin had a hard time with math - #20513 (comment)

@JmillsExpensify
C+ @thesahindia also qualifies for the bonus within 3 days - payment should be $1500

@JmillsExpensify
Copy link

Reviewed the details for @thesahindia. $1,500 approved for payment via NewDot based on BZ summary above.

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 Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

8 participants