Skip to content

[HOLD for payment 2024-07-24] Thread - LHN displays "removed 1 user" instead of "left the chat" after leaving thread #44610

Closed

Description

@izarutskaya

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

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jun 28, 2024
  2. melvin-bot commented on Jun 28, 2024

    @melvin-bot

    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.

  3. izarutskaya commented on Jun 28, 2024

    @izarutskaya
    Author

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

  4. bernhardoj commented on Jun 29, 2024

    @bernhardoj
    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.

  5. dominictb commented on Jul 1, 2024

    @dominictb
    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)

  6. melvin-bot commented on Jul 1, 2024

    @melvin-bot

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

  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 2, 2024
  8. melvin-bot commented on Jul 2, 2024

    @melvin-bot

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

  9. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 2, 2024
  10. melvin-bot commented on Jul 2, 2024

    @melvin-bot

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

  11. 21 remaining items

  12. 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[/+] on Jul 17, 2024
  13. melvin-bot commented on Jul 17, 2024

    @melvin-bot

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

  14. melvin-bot commented on Jul 17, 2024

    @melvin-bot

    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)
  15. melvin-bot commented on Jul 17, 2024

    @melvin-bot

    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:
  16. sonialiap commented on Jul 24, 2024

    @sonialiap
    Contributor

    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

  17. melvin-bot commented on Jul 24, 2024

    @melvin-bot

    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
  18. melvin-bot commented on Jul 29, 2024

    @melvin-bot

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

  19. eh2077 commented on Jul 30, 2024

    @eh2077
    Contributor

    Checklist

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions