App: [HOLD for payment 2023-08-01] [$1000] Dev: Web - Reaction does not work for first message of thread

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:

  1. Go to any chat
  2. Hover on any message and click reply in thread option
  3. In the thread, try to react on the first message

Expected Result:

Reaction should be able to be applied

Actual Result:

Reaction does not work

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.36-2 DEV Reproducible in staging?: n/a Reproducible in production?: n/a 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

https://github.com/Expensify/App/assets/93399543/eb25ff28-7fec-42a6-bf85-d2fb78a59b94

Expensify/Expensify Issue URL: Issue reported by: @gadhiyamanan Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1688456691034579

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019314fb87cf5420e8
  • Upwork Job ID: 1676593895120011264
  • Last Price Increase: 2023-07-05

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 41 (28 by maintainers)

Most upvoted comments

Now that we have a specific issue for payment I’m going to close this.

Here’s timeline analysis:

@jeet-dhandha was not assigned on this issue, but they took responsibility of fixing this as this came from their original PR.

Not overdue on my side

Regression Test Step: https://github.com/Expensify/App/issues/19363#issuecomment-1621774945

@johncschuster Can we put this issue on hold for a bit? I’m trying to get this pr merged which is going to touch the same code, and I don’t want to accidentally revert any work done here

Proposal

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

Reaction does not work for first message of thread

What is the root cause of that problem?

We pass report as child report and action as parentReportAction into ReportActionItem

https://github.com/Expensify/App/blob/15e547e3bceeb7bfe693f78fc8b90fdc28b1b32f/src/pages/home/report/ReportActionItemParentAction.js#L64-L70

When we call toggleEmojiReaction, because reportID is the current report but reportActionID is parent report action, reportAction is empty, and then this function return and do nothing.

https://github.com/Expensify/App/blob/15e547e3bceeb7bfe693f78fc8b90fdc28b1b32f/src/libs/actions/Report.js#L1644-L1648

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

We should check if reportAction is empty that mean reportActionID is the ID of parent report action, we will get the parentReport, and get the correct reportAction.

function toggleEmojiReaction(reportID, reportActionID, emoji, paramSkinTone = preferredSkinTone) {
  let currentReportID = reportID;
  let reportAction = ReportActionsUtils.getReportAction(reportID, reportActionID);

  if (_.isEmpty(reportAction)) {
      const parentReport = ReportUtils.getParentReport(ReportUtils.getReport(reportID))
      currentReportID = parentReport.reportID;
      reportAction = ReportActionsUtils.getReportAction(currentReportID, reportActionID);
  }

  if (_.isEmpty(reportAction)) {
      return;
  }

  const message = reportAction.message[0];
  const reactionObject = message.reactions && _.find(message.reactions, (reaction) => reaction.emoji === emoji.name);
  const skinTone = emoji.types === undefined ? null : paramSkinTone; // only use skin tone if emoji supports it
  if (reactionObject) {
      if (hasAccountIDReacted(currentUserAccountID, reactionObject.users, skinTone)) {
          return removeEmojiReaction(currentReportID, reportAction, emoji, skinTone);
      }
  }
  return addEmojiReaction(currentReportID, reportAction, emoji, skinTone);
}

What alternative solutions did you explore? (Optional)

NA

Result

Screencast from 05-07-2023 15:30:37.webm