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] Stop highlighting report mentions in non policy rooms in the Composer #41597

Open
rlinoz opened this issue May 3, 2024 · 21 comments
Open
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Improvement Item broken or needs improvement. Reviewing Has a PR in review Weekly KSv2

Comments

@rlinoz
Copy link
Contributor

rlinoz commented May 3, 2024

Problem:
While typing a report mention in the composer in a DM or group chat the mention is highlighted, even though it is not possible to mention a report in this types o chats.

image

Solution:
We need to stop applying the markdown style to report mentions in reports that don't belong to a group policy.

@rlinoz rlinoz added Daily KSv2 Improvement Item broken or needs improvement. labels May 3, 2024
@melvin-bot melvin-bot bot added the Overdue label May 6, 2024
@ShridharGoel
Copy link
Contributor

Proposal

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

Need to stop highlighting report mentions in non policy rooms.

What is the root cause of that problem?

As of now, mentionReport is always using theme.mentionText and theme.mentionBG in the markdown style which leads to the highlighting.

mentionReport: {
color: theme.mentionText,
backgroundColor: theme.mentionBG,
},

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

We'll add a new argument to useMarkdownStyle.

function useMarkdownStyle(message: string | null = null, shouldUseMentionReport = true)

Updated logic for styles of mentionReport:

mentionReport: {
    color: shouldUseMentionReport ? theme.mentionText : null,
    backgroundColor: shouldUseMentionReport ? theme.mentionBG : null,
},

Pass isGroupPolicyReport as a prop to Composer via ComposerWithSuggestions.

isGroupPolicyReport={isGroupPolicyReport}

We'll update Composer function signature in both index.tsx and index.native.tsx.

Now, we can pass the same to useMarkdownStyle as the value of shouldUseMentionReport by updating this code: Link.

const markdownStyle = useMarkdownStyle(value, isGroupPolicyReport);

We'll do the same in index.native.tsx also:

const markdownStyle = useMarkdownStyle(value);

@robertKozik
Copy link
Contributor

Hi @rlinoz! I'll look into it

@nkdengineer
Copy link
Contributor

nkdengineer commented May 6, 2024

Proposal

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

  • Stop highlighting report mentions in non policy rooms in the Composer

What is the root cause of that problem?

  • In here, we apply the mentionReport style without checking if the report belongs to policy or not, that leads to 2 bug:
  1. Main bug in this issue: While typing a report mention in the composer in a DM or group chat the mention is highlighted, even though it is not possible to mention a report in this types o chats.

  2. In policy room chat, when typing any room name that does not belong to the policy, the typed text is still highlighted. Then send a message. That message is still highlighted until the API AddComment is successful.

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

  • We should create a new function to check if the typed text matches the suggestedMentions.

  • For example, assume that the suggestedMentions contains a few options: [announce, admin, room-1, room-2, room-3] then if user types #room-1, the typed text is highlighted.

    If user types room-4, the typed text is not highlighted because there is no option is room-4.

  • Here is the implementation:

  1. Create a function:
function doesRoomExisted(roomName: string, listRoomName: string[]) {
    return listRoomName.includes(roomName);
} 

which its inputs are the roomName and listRoomName, and return the boolean value to know if the given room named belongs to the current policy or not . In there above example, doesRoomExisted('room-1', ['announce', 'admin', 'room-1', 'room-2', 'room-3']) returns true

  1. Then update this to:
            mentionReport: doesRoomExisted(message, listRoomName) ? {
                color: theme.mentionText,
                backgroundColor: theme.mentionBG,
            }: {},

this step is straightforward so I do not implement the details. The main idea of this step is we will check if the typed text exists in the list room that can be mentioned. If true, apply the highlight style.
Also, we need to apply the change in .native.ts file

  1. Now our main bug is fixed. But there is another issue that I mentioned in the RCA section. For example in the above example is room-4, that message is highlighted for a while before the AddComment is called successfully. It is because in here, we apply the mention-report tag in case of isGroupPolicyReport. We should use doesRoomExisted along with doesRoomExisted

What alternative solutions did you explore? (Optional)

  • NA

@nkdengineer
Copy link
Contributor

I updated the proposal

@rlinoz
Copy link
Contributor Author

rlinoz commented May 6, 2024

Sorry we aligned on Slack that this one should go to Robert since he was the one adding the styling to report mentions.

@nkdengineer
Copy link
Contributor

@rlinoz I found another related bug: In policy room chat, when typing any room name that does not belong to the policy, the typed text is still highlighted. Then send a message. That message is still highlighted until the API AddComment is successful.

Can you confirm if it is a bug? Thanks

@robertKozik
Copy link
Contributor

Hi @nkdengineer I think it's not actually a bug - If there is no rrom with such a name, we will send actionable whisper with an option to create it. Checking for the room existance is not a valid one in this case. CMIIW

@nkdengineer
Copy link
Contributor

we will send actionable whisper with an option to create it

@robertKozik This feature is not implemented in staging, right? (So I think It will be handled in the future).

Thanks for your information!

@robertKozik
Copy link
Contributor

I believe frontend implementation is already merged, only backend part is not yet in staging. But I'm not so up-to-date on it 😄

@robertKozik
Copy link
Contributor

@rlinoz I've created draft PR for this one. I went with more general solution and implement the rule excluding mechanism. Feel free to test and comment - I'll add the remaining screenshots and the rest later today.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels May 9, 2024
Copy link

melvin-bot bot commented May 15, 2024

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

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 27, 2024
@melvin-bot melvin-bot bot changed the title Stop highlighting report mentions in non policy rooms in the Composer [HOLD for payment 2024-06-03] Stop highlighting report mentions in non policy rooms in the Composer May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

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

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

@rlinoz rlinoz added the Bug Something is broken. Auto assigns a BugZero manager. label May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels May 27, 2024
@rlinoz
Copy link
Contributor Author

rlinoz commented May 27, 2024

@JmillsExpensify @mollfpr reviewed the PR.

@rlinoz
Copy link
Contributor Author

rlinoz commented May 29, 2024

Checking if we should close here #42523 (comment)

@melvin-bot melvin-bot bot added Daily KSv2 and removed Overdue Daily KSv2 labels May 29, 2024
Copy link

melvin-bot bot commented Jun 3, 2024

Payment Summary

Upwork Job

  • Reviewer: @mollfpr owed $250 via NewDot
  • Contributor: @robertKozik is from an agency-contributor and not due payment

BugZero Checklist (@JmillsExpensify)

  • 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

@SzymczakJ
Copy link
Contributor

The PR that solved this issue was reverted. I'll be taking care of this issue now 😄

@puneetlath puneetlath changed the title [HOLD for payment 2024-06-03] Stop highlighting report mentions in non policy rooms in the Composer Stop highlighting report mentions in non policy rooms in the Composer Jun 4, 2024
@rlinoz rlinoz removed the Awaiting Payment Auto-added when associated PR is deployed to production label Jun 5, 2024
@rlinoz
Copy link
Contributor Author

rlinoz commented Jun 6, 2024

Just to be sure we are waiting on this PR? Expensify/react-native-live-markdown#366

@SzymczakJ
Copy link
Contributor

Correct. There is a lot going on in react-native-live-markdown, so we will have to wait , but I'm pinging react-native-live-markdown team to merge this fix ASAP 😄

@rlinoz rlinoz changed the title Stop highlighting report mentions in non policy rooms in the Composer [HOLD] Stop highlighting report mentions in non policy rooms in the Composer Jun 6, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Jun 7, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jun 7, 2024
@SzymczakJ
Copy link
Contributor

Fix was merged into react-native-live-markdown so I'm putting the reverted PR back, but let us merge bump of react native live markdown in a separate PR, because it fixes A LOT of other issues. This should get merged pretty easily and in the meantime we can test this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Improvement Item broken or needs improvement. Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants