[$250] Mention - @expensify.sms is copied along with phone number when copied to clipboard
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:
- Go to staging.new.expensify.com
- Go to any chat
- Send a text with phone number mention
- Right click on the message > Copy to clipboard
- 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
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~01e5f15c665b86efd4
- Upwork Job ID: 1772750767801118720
- Last Price Increase: 2024-03-26
Triggered auto assignment to @greg-schroeder (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.
@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
We think that this bug might be related to #vip-vsp CC @quinthar
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 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));
@greg-schroeder Huh... This is 4 days overdue. Who can take care of this?
@greg-schroeder Still overdue 6 days?! Let's take care of this!
Apologies, I was OOO last week. I'll take a look at this shortly
Adding to #vip-vsb as this is chat-related, and I'm pretty sure this is very simple.
โ ๏ธ 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.
Job added to Upwork: https://www.upwork.com/jobs/~01e5f15c665b86efd4
Triggered auto assignment to Contributor-plus team member for initial proposal review - @alitoshmatov (External)
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
Updated proposal
Added result video
Sidenote, currently on dev we are facing infinte loop problems https://github.com/Expensify/App/issues/39028
๐ฃ @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:
- Make sure you've read and understood the contributing guidelines.
- 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.
- 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.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0131a29d57cf560448
โ Contributor details stored successfully. Thank you for contributing to Expensify!
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.
Code
} else if (messageText && messageText.endsWith(CONST.SMS.DOMAIN)) { setClipboardMessage(messageText.replace(CONST.SMS.DOMAIN, '')); }
@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?
@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
@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
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 :)
@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
but still it is not valid solution as state:
Working on the proposal, will update soon :)
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
@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
@alitoshmatov I updated my proposal based on comment
@GandalfGwaihir the issue occurs when @expensify.sms is within other text
https://github.com/Expensify/App/assets/59907218/a554f587-45df-4b78-abe0-6e0a73aee1be
๐ฃ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? ๐ธ
@alitoshmatov I updated my proposal based on comment.
@nkdengineer 's proposal looks good which suggests to remove sms domain from texts inside user mention tags
C+ reviewed ๐ ๐ ๐