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 2024-07-24] Thread - LHN displays "removed 1 user" instead of "left the chat" after leaving thread #44610

Closed
6 tasks done
izarutskaya opened this issue Jun 28, 2024 · 24 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

@izarutskaya
Copy link

izarutskaya commented Jun 28, 2024

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-3.1
Reproducible in staging?: Y
Reproducible in production?: Y
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Go to staging.new.expensify.com/
  2. Go to any chat.
  3. Send a message.
  4. Right click on the message > Reply in thread.
  5. Send a reply in thread.
  6. Click 3-dot menu > Leave.
  7. Go to the thread again.

Expected Result:

Thread in LHN will display "left the chat".

Actual Result:

Thread in LHN displays "removed 1 user" after leaving thread.

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6527092_1719558928457.20240628_151205.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @eh2077
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 28, 2024
Copy link

melvin-bot bot commented Jun 28, 2024

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

@izarutskaya
Copy link
Author

We think this issue might be related to the #vip-vsb

@bernhardoj
Copy link
Contributor

Proposal

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

The LHN shows removed 1 user instead of left the chat when leaving a thread.

What is the root cause of that problem?

Leaving a thread will add a LEAVEROOM action from the BE response.
image

And that's considered as a room change log action.

} else if (ReportActionsUtils.isRoomChangeLogAction(lastAction)) {
const lastActionOriginalMessage = lastAction?.actionName ? ReportActionsUtils.getOriginalMessage(lastAction) : null;
const targetAccountIDs = lastActionOriginalMessage?.targetAccountIDs ?? [];
const targetAccountIDsLength = targetAccountIDs.length !== 0 ? targetAccountIDs.length : report.lastMessageHtml?.match(/<mention-user[^>]*><\/mention-user>/g)?.length ?? 0;
const verb =
lastActionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastActionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM
? Localize.translate(preferredLocale, 'workspace.invite.invited')
: Localize.translate(preferredLocale, 'workspace.invite.removed');
const users = Localize.translate(preferredLocale, targetAccountIDsLength > 1 ? 'workspace.invite.users' : 'workspace.invite.user');
result.alternateText = `${lastActorDisplayName} ${verb} ${targetAccountIDsLength} ${users}`.trim();
const roomName = lastActionOriginalMessage?.roomName ?? '';
if (roomName) {
const preposition =
lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM || lastAction.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM
? ` ${Localize.translate(preferredLocale, 'workspace.invite.to')}`
: ` ${Localize.translate(preferredLocale, 'workspace.invite.from')}`;
result.alternateText += `${preposition} ${roomName}`;
}
if (lastActionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {
result.alternateText = `${lastActorDisplayName} ${Localize.translate(preferredLocale, 'roomChangeLog.updateRoomDescription')} ${
lastActionOriginalMessage?.description
}`.trim();
}
} else if (lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.LEAVE_POLICY) {

Because the action is not an invited action, the removed message is being used.

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

We can make sure the room change log condition is only true if it's not a thread.
ReportActionsUtils.isRoomChangeLogAction(lastAction) && !result.isThread.

This way, the last message of the thread report will be used, that is, left the chat.

What alternative solutions did you explore? (Optional)

We can improve the room change log message by adding the case for the leave room that returns left the chat (and it's translation). Currently, it only handles invite, remove, and update description.

@melvin-bot melvin-bot bot added the Overdue label Jul 1, 2024
@dominictb
Copy link
Contributor

Proposal

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

Thread in LHN displays "removed 1 user" after leaving thread.

What is the root cause of that problem?

In the past, we moved to this case if the report action is invite or removed action. See the diff here for more details.

Now, we use isRoomChangeLogAction function that checks whether the action is a room change log action or not and it's not correct with the previous check. And then when we leave the room, the last action is LEAVEROOM action, and removed 1 user appears.

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

We should create a new function like isInviteOrRemovedAction that will return true if the report action is one of four action types that we used in the past here.

function isInviteOrRemovedAction(reportAction: OnyxInputOrEntry<ReportAction>): reportAction is ReportAction<ValueOf<typeof CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG | typeof CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG>> {
    return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM, CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.REMOVE_FROM_ROOM, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.REMOVE_FROM_ROOM);
}

And then use this function here to update the condition correctly

What alternative solutions did you explore? (Optional)

Copy link

melvin-bot bot commented Jul 1, 2024

@sonialiap Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@sonialiap sonialiap added the External Added to denote the issue can be worked on by a contributor label Jul 2, 2024
Copy link

melvin-bot bot commented Jul 2, 2024

Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 2, 2024
Copy link

melvin-bot bot commented Jul 2, 2024

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

@eh2077

This comment was marked as outdated.

Copy link

melvin-bot bot commented Jul 3, 2024

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

@dominictb
Copy link
Contributor

dominictb commented Jul 3, 2024

@eh2077 Please see the diff, in the past we check if the action is invited or removed action for room or policy, we will move to this case and display in LHN as invited x users or removed x users.

Screenshot 2024-07-03 at 22 52 34

But isRoomChangeLogAction function check if the action is one of CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG that is not correct with the check we did in the past, this doesn't contain the case for CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM and CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.REMOVE_FROM_ROOM and has the incorrect case for LEAVEROOM

Screenshot 2024-07-03 at 22 54 07

For the UPDATEROOMDESCRIPTION case that is just added here , we can move this as a separate case to make the code more cleaner.

if (lastActionName === CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.UPDATE_ROOM_DESCRIPTION) {

@eh2077
Copy link
Contributor

eh2077 commented Jul 3, 2024

@dominictb Thanks for pointing out that! Yes, I agreed with you - we should fix the issue by checking

[
    CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.INVITE_TO_ROOM,
    CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.REMOVE_FROM_ROOM,
    CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.INVITE_TO_ROOM, 
    CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.REMOVE_FROM_ROOM
]

in method ReportActionsUtils.isRoomChangeLogAction just like we did before the refactoring.

That's said, I think we should go with @dominictb 's proposal.

@arosiclair All yours.

🎀👀🎀 C+ reviewed

Sorry for the back and forth!

Copy link

melvin-bot bot commented Jul 3, 2024

Current assignee @arosiclair is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@arosiclair
Copy link
Contributor

And then use this function here to update the condition correctly

@dominictb how should we update this exactly? I don't see where LEAVEROOM would be handled if we only check for isInviteOrRemovedAction.

@dominictb
Copy link
Contributor

@arosiclair In the past we also didn't have the special case for LEAVEROOM and we use the lastMessageText as default for this case.

@arosiclair
Copy link
Contributor

Gotcha sounds like the default text will work. Please move forward with the PR

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 4, 2024
Copy link

melvin-bot bot commented Jul 8, 2024

@arosiclair, @sonialiap, @eh2077, @dominictb Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Jul 8, 2024
@dominictb
Copy link
Contributor

PR will be ready by today

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Overdue Daily KSv2 labels Jul 9, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 17, 2024
@melvin-bot melvin-bot bot changed the title Thread - LHN displays "removed 1 user" instead of "left the chat" after leaving thread [HOLD for payment 2024-07-24] Thread - LHN displays "removed 1 user" instead of "left the chat" after leaving thread Jul 17, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 17, 2024
Copy link

melvin-bot bot commented Jul 17, 2024

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

Copy link

melvin-bot bot commented Jul 17, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.7-8 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 2024-07-24. 🎊

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

  • @eh2077 requires payment (Needs manual offer from BZ)
  • @dominictb requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Jul 17, 2024

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:

  • [@eh2077] The PR that introduced the bug has been identified. Link to the PR:
  • [@eh2077] 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:
  • [@eh2077] 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:
  • [@eh2077] Determine if we should create a regression test for this bug.
  • [@eh2077] 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.
  • [@sonialiap] 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 and removed Weekly KSv2 labels Jul 23, 2024
@sonialiap
Copy link
Contributor

sonialiap commented Jul 24, 2024

Payment summary:

  • @eh2077 $250 - offer sent in upwork - please complete the checklist - paid ✔️
  • @dominictb $250 - offer sent in upwork - paid ✔️

https://www.upwork.com/ab/applicants/1816054414293401460/job-details

Copy link

melvin-bot bot commented Jul 24, 2024

Payment Summary

Upwork Job

  • ROLE: @eh2077 paid $(AMOUNT) via Upwork (LINK)
  • ROLE: @dominictb paid $(AMOUNT) via Upwork (LINK)

BugZero Checklist (@sonialiap)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@melvin-bot melvin-bot bot added the Overdue label Jul 26, 2024
Copy link

melvin-bot bot commented Jul 29, 2024

@arosiclair, @sonialiap, @eh2077, @dominictb Huh... This is 4 days overdue. Who can take care of this?

@eh2077
Copy link
Contributor

eh2077 commented Jul 30, 2024

Checklist

@melvin-bot melvin-bot bot removed the Overdue label Jul 30, 2024
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
No open projects
Archived in project
Development

No branches or pull requests

6 participants