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

Fix #17798: Backtick Bug #19218

Closed
wants to merge 0 commits into from
Closed

Fix #17798: Backtick Bug #19218

wants to merge 0 commits into from

Conversation

AngelNBazan
Copy link
Contributor

@AngelNBazan AngelNBazan commented May 18, 2023

Details

Fixed backticks (`) display in the comment/description sections of actions such as Send Money, Request Money, and Split Bill by removing the HTML parser that processed the comment text. This change ensures that backticks are correctly displayed (`) instead of being converted into their HTML representation '&#x60'."

Fixed Issues

$ #17798
PROPOSAL: #17798 (comment)

Tests

1.Create an action(Request money, Send money, Split bill)
2. In comment/description section and add backticks(`) to text
3. Verify the correct amount of backticks are displayed, all text in between backticks is present, and backticks are displayed properly and not as html representation('&#x60')

Offline tests

N/a

QA Steps

1.Create an action(Request money, Send money, Split bill)
2. In comment/description section and add backticks(`) to text
3. Verify the correct amount of backticks are displayed, all text in between backticks is present, and backticks are displayed properly and not as html representation('&#x60')

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web

image
Screenshot 2023-05-17 at 12 28 09 PM
Screenshot 2023-05-17 at 12 27 43 PM

Mobile Web - Chrome

image
Screenshot 2023-05-18 at 11 53 28 AM

Mobile Web - Safari

image
Screenshot 2023-05-18 at 11 56 03 AM

Desktop

image
image
image

iOS

image
unnamed
unnamed (1)

Android

image
image![unnamed]
image

@AngelNBazan AngelNBazan requested a review from a team as a code owner May 18, 2023 21:41
@melvin-bot melvin-bot bot requested review from alex-mechler and mollfpr and removed request for a team May 18, 2023 21:41
@melvin-bot
Copy link

melvin-bot bot commented May 18, 2023

@alex-mechler @mollfpr One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@mollfpr
Copy link
Contributor

mollfpr commented May 19, 2023

@AngelNBazan Could you complete the screenshots for all platforms? Thanks!

@mollfpr
Copy link
Contributor

mollfpr commented May 19, 2023

@AngelNBazan I also notice that the older IOU that already saves the markdown for description still displays the issue in LHN and the expense report thread. Could we at least display the same comment within the comment in IOUPreview?

Screenshot 2023-05-19 at 21 28 17

Screenshot 2023-05-19 at 21 30 40

@AngelNBazan
Copy link
Contributor Author

@mollfpr I have just add the screenshots for all platforms and I also included screenshots of the IOUPreview working correctly with this fix.

@mollfpr
Copy link
Contributor

mollfpr commented May 22, 2023

@AngelNBazan Could you address this issue?

Screenshot 2023-05-22 at 18 32 20

@AngelNBazan
Copy link
Contributor Author

AngelNBazan commented May 22, 2023

@mollfpr I have attached some screenshots that show this PR, fixing this issue(#19218 (comment)). The reason that the older IOU displays backticks properly and the IOU preview doesn't is that we are still sending/saving improperly parsed text to the backend. And, in this PR we remove the parsing logic and save/send the plain text to the backend which is why in the screenshots below it displays properly.

const textForNewCommentDecoded = Str.htmlDecode(textForNewComment);

Screenshot 2023-05-22 at 10 22 04 AM
Screenshot 2023-05-22 at 10 22 47 AM
Screenshot 2023-05-22 at 10 38 25 AM

@mollfpr
Copy link
Contributor

mollfpr commented May 22, 2023

@AngelNBazan So can we fix that? Or we only able to fix the issue in new IOU?

@AngelNBazan
Copy link
Contributor Author

@mollfpr Sorry, I'm a bit confused about what you mean by "Or we only able to fix the issue in new IOU", this PR would remove the parsing logic. Removing the parsing logic is how we fix this issue #19218 (comment), as it saves the correct text across everything. So, whenever anything uses the comments/descriptions it accesses the correct text.

@AngelNBazan
Copy link
Contributor Author

@mollfpr Oh, sorry, I think I understand now. Yes, this PR would only apply to IOUs from now on. Therefore, old IOUs would still display incorrectly. I'm not sure on how we could fix old IOUs as those have already been saved to the backend.

@mollfpr
Copy link
Contributor

mollfpr commented May 23, 2023

@AngelNBazan Is it possible to display the exact text on the sidebar and the IOU preview comment?

@AngelNBazan
Copy link
Contributor Author

@mollfpr Yes, here are screenshots of that.
Screenshot 2023-05-23 at 10 38 39 AM
Screenshot 2023-05-23 at 10 37 56 AM

@mollfpr
Copy link
Contributor

mollfpr commented May 23, 2023

Nice! Let's stick with that and keep the original solution too.

@AngelNBazan
Copy link
Contributor Author

@mollfpr Alright, that sounds good to me. I believe my PR is now ready for review. Could you please take a look at it? Thank you!

@mollfpr
Copy link
Contributor

mollfpr commented May 23, 2023

@AngelNBazan I think there's a misunderstanding here. I'm asking for the older IOU since. 😅

@AngelNBazan
Copy link
Contributor Author

@mollfpr Sorry for the confusion 😅. Could you please provide more clarification on what you mean by the 'older IOU'? I want to make sure I understand your request correctly. Thank you!

@mollfpr
Copy link
Contributor

mollfpr commented May 23, 2023

The screenshot here is has request money before this PR created. In LHN it's and description display &#x60;&#x60; but it's show '' in the IOU preview.

So I'm thinking we could fix the incorrect text for old IOUs too, because it's fix in the IOU preview component.

@AngelNBazan
Copy link
Contributor Author

AngelNBazan commented May 23, 2023

@mollfpr, I understand now. We actually cannot fix old IOUs because the text has already been saved incorrectly. The reason that it shows correctly in the screenshots is because something similar to this PR was started but not finished:

message: getIOUReportActionMessage(type, amount, textForNewCommentDecoded, currency, paymentType, isSettlingUp),

In this case, textForNewCommentDecoded will save the correct text for IOUPreview. However, in the two lines below, we still save the incorrect text to the backend, and the LHN and description will receive &#x60;. It is not possible to rewrite this as it has already been saved to the report.

const textForNewComment = parser.htmlToText(commentText);

comment: textForNewComment,

This PR aims to fix these two lines above and other locations where incorrect text is still being sent. So to summarize, this PR will only fix new IOUs and will have LHN and descriptions display the correct text #19218 (comment). These screenshots were taken of me testing the PR with new IOUs, not old ones. Hope this clears up any misunderstandings. 😄

@mollfpr
Copy link
Contributor

mollfpr commented May 24, 2023

So to summarize, this PR will only fix new IOUs and will have LHN and descriptions display the correct text #19218 (comment). These #19218 (comment) were taken of me testing the PR with new IOUs, not old ones.

@alex-mechler Are we okay with this? We could decode the text in LHN for the last message or the display name, but if the user tries to leave a comment with & , © , etc, it will be decoded, and I'm afraid someone will see that as a bug.

@alex-mechler
Copy link
Contributor

if the user tries to leave a comment with & , © , etc, it will be decoded, and I'm afraid someone will see that as a bug.

Can you elaborate on this? With this PR in place, if you comment with &, what will the user see?

For the scope of this issue, we can ignore pre-existing IOUs, and only worry about ones going forward

@mollfpr
Copy link
Contributor

mollfpr commented May 25, 2023

Can you elaborate on this? With this PR in place, if you comment with &, what will the user see?

In this PR, the user will see what they send so it's still &. I forgot what point I tried to explain there. 😅

For the scope of this issue, we can ignore pre-existing IOUs, and only worry about ones going forward

Okay then, I'll continue with the review and testing. Thanks for confirming it @alex-mechler!

@mollfpr
Copy link
Contributor

mollfpr commented May 25, 2023

@AngelNBazan Do we still need this parsed?

html: getParsedComment(iouMessage),

@AngelNBazan
Copy link
Contributor Author

@mollfpr No, you're right this does not need to parsed I have just updated the PR.

@fedirjh
Copy link
Contributor

fedirjh commented May 25, 2023

@mollfpr, @AngelNBazan I am not sure , but maybe we can cleanup IOUPreview.js as well , Specifically this line

const requestComment = Str.htmlDecode(moneyRequestAction.comment).trim();

@mollfpr
Copy link
Contributor

mollfpr commented May 29, 2023

@AngelNBazan Could you resolve the conflicts? I'll complete the review afterward.

@AngelNBazan
Copy link
Contributor Author

Sure, @mollfpr! I have just resolved the conflicts. Let me know if there's anything else I can help with.

Copy link
Contributor

@mollfpr mollfpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay! Just need to revert unnecessary changes on IOUPreview.

@mollfpr
Copy link
Contributor

mollfpr commented May 30, 2023

While testing this PR, I reported a bug in the Split bill details page here.

@mollfpr
Copy link
Contributor

mollfpr commented May 30, 2023

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
19218.Web.mov
Mobile Web - Chrome
19218.mWeb.Chrome.mov
Mobile Web - Safari
19218.mWeb.Safari.mp4
Desktop
19218.Desktop.mov
iOS
19218.iOS.mp4
Android
19218.Android.mov

Copy link
Contributor

@mollfpr mollfpr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and tests well 👍

All yours @alex-mechler

@alex-mechler
Copy link
Contributor

@AngelNBazan Code LGTM, and tests well, but you still have unsigned commits here. You need to make this PR have only signed commits before travis will pass

@AngelNBazan
Copy link
Contributor Author

@mollfpr @alex-mechler, apologies for the inconvenience. I had to recreate the repo to sign all the commits. Here's the new PR: #19868.

@alex-mechler
Copy link
Contributor

Thanks!

@alex-mechler alex-mechler mentioned this pull request May 31, 2023
56 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants