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 precision error when creating distance request #28734

Merged
merged 2 commits into from
Oct 4, 2023

Conversation

aldo-expensify
Copy link
Contributor

@aldo-expensify aldo-expensify commented Oct 3, 2023

Details

Found that the distance request can trigger a validation error if the two locations chosen cause the amount to have lots of decimals.
See: #28721 (comment)

Fixed Issues

$ #28721 (comment)
PROPOSAL:

Tests

  1. Create account with workspace
  2. Click the big + green plus button and select "Request Money"
  3. Select "Distance"
  4. Enter "Heather Street" and select the address in Vancouver as the "FROM"
  5. Enter "2020 Highbury Street" and select the option in Vancouver as the "TO"
  6. Create the money request and verify that it doesn't error out

Added automated test

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Create account with workspace
  2. Click the big + green plus button and select "Request Money"
  3. Select "Distance"
  4. Enter "Heather Street" and select the address in Vancouver as the "FROM"
  5. Enter "2020 Highbury Street" and select the option in Vancouver as the "TO"
  6. Create the money request and verify that it doesn't error out
  • 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
    • If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
    • 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 the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • 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
Screen.Recording.2023-10-03.at.12.51.46.PM.mov
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android

@aldo-expensify aldo-expensify requested a review from a team as a code owner October 3, 2023 16:04
@aldo-expensify aldo-expensify self-assigned this Oct 3, 2023
@melvin-bot melvin-bot bot requested review from s77rt and removed request for a team October 3, 2023 16:04
@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2023

@s77rt Please 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]

@aldo-expensify
Copy link
Contributor Author

cc @hayata-suenaga does rounding sound like the right thing to do here? or would it be better to ceil/floor? or something else?

Beamanator
Beamanator previously approved these changes Oct 4, 2023
Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

LGTM (one tiny NAB)

src/libs/DistanceRequestUtils.js Outdated Show resolved Hide resolved
Co-authored-by: Alex Beaman <alexbeaman@expensify.com>
Copy link
Contributor

@Beamanator Beamanator left a comment

Choose a reason for hiding this comment

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

LGTM

@Beamanator
Copy link
Contributor

Beamanator commented Oct 4, 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 the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • 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
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android

@Beamanator Beamanator merged commit ec4b380 into main Oct 4, 2023
11 of 12 checks passed
@Beamanator Beamanator deleted the aldo_distance-request-amount-cents branch October 4, 2023 15:04
@OSBotify
Copy link
Contributor

OSBotify commented Oct 4, 2023

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions github-actions bot added the DeployBlockerCash This issue or pull request should block deployment label Oct 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2023

Performance Comparison Report 📊

Significant Changes To Duration

Name Duration
App start TTI 1213.208 ms → 1280.169 ms (+66.961 ms, +5.5%) 🔴
Show details
Name Duration
App start TTI Baseline
Mean: 1213.208 ms
Stdev: 28.665 ms (2.4%)
Runs: 1147.068026999943 1159.7836269999389 1169.638942999998 1181.1573479999788 1186.2530459999107 1188.73837799998 1189.1193959999364 1197.3381739999168 1197.515837999992 1207.2846909998916 1208.529908000026 1209.2103999999817 1211.1251250000205 1213.3456470000092 1214.3821829999797 1220.5978570000734 1222.4743679999374 1223.8371129999869 1224.4001070000231 1224.4770879999269 1225.1574190000538 1226.9599530000705 1230.5866199999582 1233.8765960000455 1243.931489000097 1245.2690099999309 1247.1273650000803 1247.775246999925 1286.0603070000652

Current
Mean: 1280.169 ms
Stdev: 37.598 ms (2.9%)
Runs: 1224.574200999923 1229.1673129999544 1230.2646600001026 1238.041930000065 1239.3273710000794 1240.867230999982 1245.679186000023 1246.7476609998848 1251.226195000112 1252.6683499999344 1253.0393399999011 1259.4762260001153 1259.7308479999192 1260.24847900006 1260.32308500004 1273.790219000075 1278.5271230000071 1280.409331999952 1285.3503729999065 1289.6369290000293 1294.5584120000713 1298.425620000111 1311.8606360000558 1313.1580779999495 1315.2689980000723 1316.3684869999997 1317.90046299994 1324.7556839999743 1327.9631280000322 1330.2260590000078 1348.6999530000612 1367.1129240000155

Meaningless Changes To Duration

Show entries
Name Duration
App start runJsBundle 844.000 ms → 893.906 ms (+49.906 ms, +5.9%)
Open Search Page TTI 619.245 ms → 632.198 ms (+12.953 ms, +2.1%)
App start regularAppStart 0.018 ms → 0.015 ms (-0.003 ms, -16.9%) 🟢
App start nativeLaunch 22.313 ms → 21.581 ms (-0.732 ms, -3.3%)
Show details
Name Duration
App start runJsBundle Baseline
Mean: 844.000 ms
Stdev: 25.711 ms (3.0%)
Runs: 795 799 804 804 817 819 821 822 827 832 837 837 840 842 843 846 847 847 854 854 855 858 858 859 862 867 873 878 883 890 894

Current
Mean: 893.906 ms
Stdev: 26.063 ms (2.9%)
Runs: 852 853 858 861 862 866 868 870 872 873 878 883 883 887 888 894 894 902 902 905 905 906 908 913 915 920 921 921 924 925 948 948
Open Search Page TTI Baseline
Mean: 619.245 ms
Stdev: 18.944 ms (3.1%)
Runs: 579.5297860000283 590.4508869999554 592.9932870001066 594.1680099999066 600.4098710000981 601.6499840000179 603.9696859999094 604.1117360000499 609.2534590000287 609.3094480000436 611.2338469999377 611.2930100001395 612.6968590000179 616.1440840000287 616.7846279998776 617.3459469999652 619.0493570000399 620.4222820000723 620.6291910000145 622.3725990001112 622.8777260000352 629.1062829999719 629.6790370000526 630.4844980000053 630.5431319999043 631.1323249998968 635.7147630001418 638.7569579998963 645.2953290001024 650.1651609998662 650.5543629999738 667.7267660000362

Current
Mean: 632.198 ms
Stdev: 23.710 ms (3.8%)
Runs: 597.4659840001259 604.5863850000314 605.9263100000098 610.625163000077 610.911174000008 611.3721110001206 611.4903569999151 613.3887940000277 613.6842449998949 617.5990810000803 617.6205249999184 618.346923999954 618.95442799991 619.6630450000521 621.0343829998747 626.7990320001263 627.0641690001357 627.7344980000053 630.090089000063 630.6488850000314 631.8801279999316 633.5063069998287 635.5784509999212 635.9776209997945 637.7027179999277 645.2925619999878 658.6280920000281 663.1781829998363 669.0014240001328 669.6899419999681 676.1926279999316 684.5569249999244 686.3587650000118
App start regularAppStart Baseline
Mean: 0.018 ms
Stdev: 0.002 ms (9.8%)
Runs: 0.015178000088781118 0.01615400006994605 0.016193999908864498 0.0165200000628829 0.01684599998407066 0.016887000063434243 0.017008000053465366 0.017008000053465366 0.017089999979361892 0.017170999897643924 0.017171000130474567 0.01725299982354045 0.017333999974653125 0.01737500005401671 0.017903999891132116 0.017943999962881207 0.01818799995817244 0.018229000037536025 0.0186769999563694 0.01871700002811849 0.01871700002811849 0.018798999954015017 0.018839000025764108 0.01920600002631545 0.019613000098615885 0.020141999935731292 0.02034499985165894 0.020629999926313758 0.021524999989196658 0.02242000005207956 0.022704999893903732

Current
Mean: 0.015 ms
Stdev: 0.001 ms (6.2%)
Runs: 0.013752999948337674 0.014078000094741583 0.014201000100001693 0.01432300009764731 0.014405000023543835 0.014444999862462282 0.014445000095292926 0.014485999941825867 0.014567000092938542 0.014567000092938542 0.014607999939471483 0.014649000018835068 0.014770000008866191 0.014771000016480684 0.014851999934762716 0.014933000085875392 0.015137000009417534 0.015217999927699566 0.015339999925345182 0.015379999997094274 0.015542999841272831 0.015543000074103475 0.015583999920636415 0.015706000151112676 0.015992000000551343 0.01615400006994605 0.016235999995842576 0.01643799990415573 0.0165200000628829 0.016723999986425042 0.01831099996343255
App start nativeLaunch Baseline
Mean: 22.313 ms
Stdev: 2.866 ms (12.8%)
Runs: 19 19 19 19 19 20 20 20 20 20 20 20 21 21 21 22 22 22 23 23 23 23 23 24 24 24 26 26 26 27 28 30

Current
Mean: 21.581 ms
Stdev: 1.582 ms (7.3%)
Runs: 19 19 20 20 20 20 20 20 20 21 21 21 21 21 21 21 22 22 22 22 22 22 22 23 23 23 23 24 24 25 25

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2023

@Expensify/mobile-deployers 📣 Please look into this performance regression as it's a deploy blocker.

@aldo-expensify aldo-expensify removed the DeployBlockerCash This issue or pull request should block deployment label Oct 4, 2023
@aldo-expensify
Copy link
Contributor Author

False positive, adding a Math.round in this method that is not even called during rendering won't affect performance significantly.

@OSBotify
Copy link
Contributor

OSBotify commented Oct 5, 2023

🚀 Deployed to staging by https://github.com/Beamanator in version: 1.3.78-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Oct 6, 2023

🚀 Deployed to production by https://github.com/Beamanator in version: 1.3.78-4 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Oct 6, 2023

🚀 Deployed to staging by https://github.com/Beamanator in version: 1.3.79-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Oct 9, 2023

🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.79-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 failure ❌
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Oct 9, 2023

🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.79-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 cancelled 🔪
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

OSBotify commented Oct 9, 2023

🚀 Deployed to production by https://github.com/jasperhuangg in version: 1.3.79-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

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.

3 participants