App icon indicating copy to clipboard operation
App copied to clipboard

[$250] Mention - @expensify.sms is copied along with phone number when copied to clipboard

Open lanitochka17 opened this issue 1 year ago โ€ข 17 comments

If you havenโ€™t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.51-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: N/A Issue reported by: Applause - Internal Team

Issue found when executing PR https://github.com/Expensify/App/pull/37559

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to any chat
  3. Send a text with phone number mention
  4. Right click on the message > Copy to clipboard
  5. Paste the content in the composer

Expected Result:

@expensify.sms will not be copied along with phone number

Actual Result:

@expensify.sms is copied along with phone number

Workaround:

Unknown

Platforms:

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

  • [x] Android: Native
  • [x] Android: mWeb Chrome
  • [x] iOS: Native
  • [x] iOS: mWeb Safari
  • [x] MacOS: Chrome / Safari
  • [x] MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/1a12bd14-5e67-4dd5-81d9-f3c955c775d9

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01e5f15c665b86efd4
  • Upwork Job ID: 1772750767801118720
  • Last Price Increase: 2024-03-26

lanitochka17 avatar Mar 12 '24 21:03 lanitochka17

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

melvin-bot[bot] avatar Mar 12 '24 21:03 melvin-bot[bot]

@greg-schroeder FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

lanitochka17 avatar Mar 12 '24 21:03 lanitochka17

We think that this bug might be related to #vip-vsp CC @quinthar

lanitochka17 avatar Mar 12 '24 21:03 lanitochka17

Proposal

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

  • Mention - @expensify.sms is copied along with phone number when copied to clipboard

What is the root cause of that problem?

  • In here we are using the messageHtml to get the copy text in case of this bug

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

  • We can use:
    setClipboardMessage(content.replace(/(<mention-user>)(.*?)(<\/mention-user>)/gi, function(match, openTag, content, closeTag) {
                        // Replace email addresses inside content with *****
                        content = content.replace(new RegExp(EMAIL_PART, "gim"), (match)=>Str.removeSMSDomain(match))
                        // Return the modified content inside the tags
                        return openTag + content + closeTag;
                    }));

in here and here

  • In the above, (<mention-user>)(.*?)(<\/mention-user> is the regex matching all the text inside mention-user tag, which will handle the case user types "[email protected]" directly, in this case, we should not remove the "@expensify.com", EMAIL_PART = ([\\w\\-\\+\\'#]+(?:\\.[\\w\\-\\'\\+]+)*@(?:[\\w\\-]+\\.)+[a-z]{2,})" is regex matching an text containing an email (we already used it in here)

  • Or we can just use:

  setClipboardMessage(content.replace(/(<mention-user>)(.*?)(<\/mention-user>)/gi, function(match, openTag, content, closeTag) {
                        content = Str.removeSMSDomain(content);
                        return openTag + content + closeTag;
                    }));

What alternative solutions did you explore? (Optional)

  • We also can update this to:
            const messageHtml = Str.removeSMSDomain(getActionHtml(reportAction));

nkdengineer avatar Mar 13 '24 03:03 nkdengineer

@greg-schroeder Huh... This is 4 days overdue. Who can take care of this?

melvin-bot[bot] avatar Mar 18 '24 19:03 melvin-bot[bot]

@greg-schroeder Still overdue 6 days?! Let's take care of this!

melvin-bot[bot] avatar Mar 20 '24 19:03 melvin-bot[bot]

Apologies, I was OOO last week. I'll take a look at this shortly

greg-schroeder avatar Mar 25 '24 11:03 greg-schroeder

Adding to #vip-vsb as this is chat-related, and I'm pretty sure this is very simple.

greg-schroeder avatar Mar 26 '24 22:03 greg-schroeder

โš ๏ธ Could not update price automatically because there is no linked Upwork Job ID. The BZ team member will need to update the price manually in Upwork.

melvin-bot[bot] avatar Mar 26 '24 22:03 melvin-bot[bot]

Job added to Upwork: https://www.upwork.com/jobs/~01e5f15c665b86efd4

melvin-bot[bot] avatar Mar 26 '24 22:03 melvin-bot[bot]

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

melvin-bot[bot] avatar Mar 26 '24 22:03 melvin-bot[bot]

Proposal

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

@expensify.sms is copied along with phone number when copied to clipboard

What is the root cause of that problem?

We set the html message received without checking if it is the @expensfiy.sms domain https://github.com/Expensify/App/blob/91d7eb22b3cf0e690271a1313bf8016d03cb3ef7/src/pages/home/report/ContextMenu/ContextMenuActions.tsx#L344

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

We need to use Str.removeSMSDomain from expensify-common to remove the sms domain

It would be probably good to apply this filtering formessageText as well: https://github.com/Expensify/App/blob/91d7eb22b3cf0e690271a1313bf8016d03cb3ef7/src/pages/home/report/ContextMenu/ContextMenuActions.tsx#L345

Result

https://github.com/Expensify/App/assets/110545952/22fb9bbf-82fd-4486-9615-d35c081a5d1d

allgandalf avatar Mar 27 '24 01:03 allgandalf

Updated proposal

Added result video

Sidenote, currently on dev we are facing infinte loop problems https://github.com/Expensify/App/issues/39028

allgandalf avatar Mar 27 '24 01:03 allgandalf

๐Ÿ“ฃ @Ozeias01Nunes! ๐Ÿ“ฃ Hey, it seems we donโ€™t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details. Screen Shot 2022-11-16 at 4 42 54 PM Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

melvin-bot[bot] avatar Mar 27 '24 22:03 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131a29d57cf560448

Ozeias01Nunes avatar Mar 27 '24 22:03 Ozeias01Nunes

โœ… Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Mar 27 '24 22:03 melvin-bot[bot]

Proposal

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

@expensify.sms is copied along with phone number when copied to clipboard

What is the root cause of that problem?

We set the html message received without checking if it is the @expensfiy.sms domain

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

Whether the text of the selected message ends with the SMS domain. If this happens, I replace the domain with an empty string.

Screen recording demonstrating expected operation.

https://github.com/Expensify/App/assets/20213409/f8cdfce6-7a35-49bd-b3fc-5be8f0df2540

Screenshot of solution code.

2024-04-02_13-15

Code } else if (messageText && messageText.endsWith(CONST.SMS.DOMAIN)) { setClipboardMessage(messageText.replace(CONST.SMS.DOMAIN, '')); }

Ozeias01Nunes avatar Mar 28 '24 05:03 Ozeias01Nunes

@nkdengineer Thank you for your proposal, It seems like you overcomplicated your approach, can't we just get text inside mention-user tag and remove sms domain addition with Str.removeSmsDomain?

alitoshmatov avatar Apr 01 '24 20:04 alitoshmatov

@GandalfGwaihir Thank you for your proposal, your proposal is very similar to @nkdengineer alternative solution. Also it has a drawback which is that it is removing sms domain from whole text, for example if user just enters @expensify.sms it will disappear

alitoshmatov avatar Apr 01 '24 20:04 alitoshmatov

@Ozeias01Nunes Thank you for your proposal, I think you are not approaching this problem right, for example your solution is only works when user number is only text in comment

alitoshmatov avatar Apr 01 '24 20:04 alitoshmatov

your proposal is very similar to @nkdengineer alternative solution

Hello @alitoshmatov , @nkdengineer wrote their alternate proposal after I posted my proposal, you can check the timestamps as well :)

image

allgandalf avatar Apr 01 '24 20:04 allgandalf

@GandalfGwaihir I see, but still it is not valid solution as I stated above:

Also it has a drawback which is that it is removing sms domain from whole text, for example if user just enters @expensify.sms it will disappear

alitoshmatov avatar Apr 01 '24 20:04 alitoshmatov

but still it is not valid solution as state:

Working on the proposal, will update soon :)

allgandalf avatar Apr 01 '24 20:04 allgandalf

Also it has a drawback which is that it is removing sms domain from whole text, for example if user just enters @expensify.sms it will disappear

@alitoshmatov , i tested out the solution and it doesn't have that regression, you can check the attached video:

https://github.com/Expensify/App/assets/110545952/cfd20673-cce4-4e43-b85e-1587f367898d

Am i missing your exact doubt here ?, do let me know if you need a test branch

allgandalf avatar Apr 01 '24 20:04 allgandalf

@GandalfGwaihir Your main proposal and my alternative solution is different. Your proposal will use removeSmsDomain in here: https://github.com/Expensify/App/blob/91d7eb22b3cf0e690271a1313bf8016d03cb3ef7/src/pages/home/report/ContextMenu/ContextMenuActions.tsx#L345

My proposal will use removeSmsDomain in here: https://github.com/Expensify/App/blob/14ff9445d22bd92d0645abd456ac805cedc06c28/src/pages/home/report/ContextMenu/ContextMenuActions.tsx#L346

nkdengineer avatar Apr 02 '24 00:04 nkdengineer

@alitoshmatov I updated my proposal based on comment

nkdengineer avatar Apr 02 '24 00:04 nkdengineer

@GandalfGwaihir the issue occurs when @expensify.sms is within other text

https://github.com/Expensify/App/assets/59907218/a554f587-45df-4b78-abe0-6e0a73aee1be

alitoshmatov avatar Apr 02 '24 08:04 alitoshmatov

๐Ÿ“ฃ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? ๐Ÿ’ธ

melvin-bot[bot] avatar Apr 02 '24 16:04 melvin-bot[bot]

@alitoshmatov I updated my proposal based on comment.

Ozeias01Nunes avatar Apr 02 '24 16:04 Ozeias01Nunes

@nkdengineer 's proposal looks good which suggests to remove sms domain from texts inside user mention tags

C+ reviewed ๐ŸŽ€ ๐Ÿ‘€ ๐ŸŽ€

alitoshmatov avatar Apr 02 '24 18:04 alitoshmatov