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-10-30] [$500] Chat - Enter to save display name triggers mention suggestion #29351

Closed
2 of 6 tasks
kbecciv opened this issue Oct 11, 2023 · 22 comments
Closed
2 of 6 tasks
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

@kbecciv
Copy link

kbecciv commented Oct 11, 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!


Version Number: 1.3.80.0
Reproducible in staging?: y
Reproducible in production?: y
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
Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1696919926668389

Action Performed:

  1. Open the app
  2. Open any report
  3. Type @ to trigger mention
  4. Open settings->profile->display name
  5. Make any changes and click enter to save display name
  6. Observe that even though RHN is open, mention suggestion is triggered

Expected Result:

App should not trigger mention suggestion on enter to save display name

Actual Result:

App triggers mention suggestion on enter to save display name

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

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
windows.chrome.enter.to.save.triggers.mention.mp4
mac.chrome.enter.to.save.display.name.triggers.mention.mov
MacOS: Desktop
mac.desktop.enter.to.save.display.name.triggers.mention.mov

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019fa1819aae529647
  • Upwork Job ID: 1712163978964910080
  • Last Price Increase: 2023-10-18
  • Automatic offers:
    • Ollyws | Reviewer | 27263998
    • alitoshmatov | Contributor | 27264000
    • dhanashree-sawant | Reporter | 27264004
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 11, 2023
@melvin-bot melvin-bot bot changed the title Chat - Enter to save display name triggers mention suggestion [$500] Chat - Enter to save display name triggers mention suggestion Oct 11, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 2023

Job added to Upwork: https://www.upwork.com/jobs/~019fa1819aae529647

@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 2023

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

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

melvin-bot bot commented Oct 11, 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

@melvin-bot
Copy link

melvin-bot bot commented Oct 11, 2023

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

@ZhenjaHorbach
Copy link
Contributor

ZhenjaHorbach commented Oct 11, 2023

Proposal

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

App triggers mention suggestion on enter to save display name

What is the root cause of that problem?

Since the MentionSuggestions is still not unmount we are able to contact him

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

I think the best way to fix it add isFocused for MentionSuggestions to make sure that MentionSuggestions will never be active while it is not in focus and this solution should not cause any regression

We can add

const isFocused = useNavigation().isFocused(); // optional useIsFocused

And then update this line like

    if (!isMentionSuggestionsMenuVisible || !isFocused) {
        return null;
    }

if (!isMentionSuggestionsMenuVisible) {
return null;
}

What alternative solutions did you explore? (Optional)

NA

@alitoshmatov
Copy link
Contributor

alitoshmatov commented Oct 11, 2023

Proposal

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

Updating profile data triggers mentions suggestion.

What is the root cause of that problem?

Actually pressing Enter key is not required, notice that only if you update your display name it will trigger mentions. That is because calculateMentionSuggestion, which determines if suggestion should display or not is dependent on personalDetails. That is why when you update your display name it will trigger calculateMentionSuggestion function and all conditions are met to show mentions.

const calculateMentionSuggestion = useCallback(
(selectionEnd) => {
if (shouldBlockCalc.current || selectionEnd < 1) {
shouldBlockCalc.current = false;
resetSuggestions();
return;
}
const valueAfterTheCursor = value.substring(selectionEnd);
const indexOfFirstWhitespaceCharOrEmojiAfterTheCursor = valueAfterTheCursor.search(CONST.REGEX.NEW_LINE_OR_WHITE_SPACE_OR_EMOJI);
let indexOfLastNonWhitespaceCharAfterTheCursor;
if (indexOfFirstWhitespaceCharOrEmojiAfterTheCursor === -1) {
// we didn't find a whitespace/emoji after the cursor, so we will use the entire string
indexOfLastNonWhitespaceCharAfterTheCursor = value.length;
} else {
indexOfLastNonWhitespaceCharAfterTheCursor = indexOfFirstWhitespaceCharOrEmojiAfterTheCursor + selectionEnd;
}
const leftString = value.substring(0, indexOfLastNonWhitespaceCharAfterTheCursor);
const words = leftString.split(CONST.REGEX.SPACE_OR_EMOJI);
const lastWord = _.last(words);
let atSignIndex;
if (lastWord.startsWith('@')) {
atSignIndex = leftString.lastIndexOf(lastWord);
}
const prefix = lastWord.substring(1);
const nextState = {
suggestedMentions: [],
atSignIndex,
mentionPrefix: prefix,
};
const isCursorBeforeTheMention = valueAfterTheCursor.startsWith(lastWord);
if (!isCursorBeforeTheMention && isMentionCode(lastWord)) {
const suggestions = getMentionOptions(personalDetails, prefix);
nextState.suggestedMentions = suggestions;
nextState.shouldShowSuggestionMenu = !_.isEmpty(suggestions);
}
setSuggestionValues((prevState) => ({
...prevState,
...nextState,
}));
setHighlightedMentionIndex(0);
},
[getMentionOptions, personalDetails, resetSuggestions, setHighlightedMentionIndex, value],
);

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

I think the best approach is to prevent suggestion from displaying when composer is not focused. We can achieve this by passing textInputRef.current.isFocused() to Suggestions component as isFocused here:


And pass it to SuggestionMention component from Suggestions here:

We can either add condition to here(I prefer this one since it prevents complicated calculations too)

if (shouldBlockCalc.current || selectionEnd < 1) {

or here

if (!isMentionSuggestionsMenuVisible) {

What alternative solutions did you explore? (Optional)

@Ollyws
Copy link
Contributor

Ollyws commented Oct 12, 2023

@ZhenjaHorbach Thanks for your proposal but using navigation focus here will still allow the suggestions menu to be opened by changing the display name from another window.

As far as I can see the conditions for displaying the suggestions menu should be: The composer is focused and @ is entered. So I think @alitoshmatov's proposal is the way to go here.

🎀👀🎀 C+ reviewed

@melvin-bot
Copy link

melvin-bot bot commented Oct 12, 2023

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

@melvin-bot melvin-bot bot added the Overdue label Oct 16, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 16, 2023

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

@conorpendergrast
Copy link
Contributor

@deetergp Bump on the proposal review please!

@melvin-bot melvin-bot bot removed the Overdue label Oct 17, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@deetergp
Copy link
Contributor

I agree with @Ollyws, let's go with @alitoshmatov's very clear proposal. 👍

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

melvin-bot bot commented Oct 18, 2023

📣 @Ollyws 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

📣 @alitoshmatov 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer 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 📖

@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

📣 @dhanashree-sawant 🎉 An offer has been automatically sent to your Upwork account for the Reporter role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@melvin-bot melvin-bot bot added Reviewing Has a PR in review and removed Daily KSv2 labels Oct 19, 2023
@melvin-bot melvin-bot bot added the Weekly KSv2 label Oct 19, 2023
@alitoshmatov
Copy link
Contributor

PR is ready - #29951

@melvin-bot
Copy link

melvin-bot bot commented Oct 20, 2023

🎯 ⚡️ Woah @Ollyws / @alitoshmatov, great job pushing this forwards! ⚡️

The pull request got merged within 3 working days of assignment, so this job is eligible for a 50% #urgency bonus 🎉

  • when @alitoshmatov got assigned: 2023-10-18 17:58:49 Z
  • when the PR got merged: 2023-10-20 18:12:06 UTC

On to the next one 🚀

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Oct 23, 2023
@melvin-bot melvin-bot bot changed the title [$500] Chat - Enter to save display name triggers mention suggestion [HOLD for payment 2023-10-30] [$500] Chat - Enter to save display name triggers mention suggestion Oct 23, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Oct 23, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 23, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 23, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.3.88-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-10-30. 🎊

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

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

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 Oct 23, 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:

  • [@Ollyws] The PR that introduced the bug has been identified. Link to the PR:
  • [@Ollyws] 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:
  • [@Ollyws] 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:
  • [@Ollyws] Determine if we should create a regression test for this bug.
  • [@Ollyws] 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.
  • [@conorpendergrast] 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 Oct 29, 2023
@Ollyws
Copy link
Contributor

Ollyws commented Oct 30, 2023

BugZero Checklist:

  • The PR that introduced the bug has been identified. Link to the PR:

#27327

  • 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:

https://github.com/Expensify/App/pull/27327/files#r1375955336

  • 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:

N/A

  • Determine if we should create a regression test for this bug.

I don't think a regression test would be helpful here as it's a very edge case scenario that doesn't affect the flow in any meaningful way.

@conorpendergrast
Copy link
Contributor

Payouts due:

  • Contributor+: @Ollyws requires payment of $500 + 50% urgency bonus = $750 offer (Reviewer)
  • Contributor: @alitoshmatov requires payment of $500 + 50% urgency bonus = $750 offer (Contributor)
  • Issue Reporter: @dhanashree-sawant requires payment of $50 offer (Reporter)

Eligible for 50% #urgency bonus? Yes

Upwork job is here.

All done, thanks everyone

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
None yet
Development

No branches or pull requests

6 participants