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 split bill flow in App #13385

Merged
merged 6 commits into from
Dec 20, 2022
Merged

Fix split bill flow in App #13385

merged 6 commits into from
Dec 20, 2022

Conversation

luacmartins
Copy link
Contributor

@luacmartins luacmartins commented Dec 7, 2022

Details

Refactors SplitBill to have the expected behavior

cc @mountiny @aldo-expensify since you reviewed the original split bill PR

Fixed Issues

$ #13378

Tests

No extra groups created

  1. As memberA: create a groupDM with memberB, memberC & memberD
  2. Go to the “+” menu inside the groupDM > click “Split bill”
  3. Enter $100 > click Next
  4. Deselect memberD > click Split $100
  5. The split message from memberA is added to the groupDM: Split $100 with memberB and memberC
  6. In the memberA:memberB DM the request action from memberA is added: Requested $33.33 from memberB
  7. In the memberA:memberC DM the request action from memberA is added: Requested $33.33 from memberC
  8. In the memberA:memberD DM there is nothing added, as memberD was excluded from the split.

Splitting a bill with a single participant

  1. As memberA, create a groupDM with memberB and memberC
  2. Go to the + menu inside the groupDM > click Split bill
  3. Enter $100 > click Next
  4. Deselect memberC > click Split $100
  5. The split message from memberA is added to the groupDM: Split $100 with memberB
  6. In the memberA:memberB DM the request action from memberA is added: Requested $50.00 from memberB
  7. In the memberA:memberC DM there is nothing added, as memberC was excluded from the split.

Split a bill from a policy room

  1. Create a Workspace + > New Workspace
  2. Navigate to Workspace > Manage members > Invite
  3. Invite 10 members to the policy
  4. In the announce room, select Split bill from the + icon inside the chat
  5. Verify that there's a split message added to the room and no additional group chats are created
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests steps but the Split and Requested messages will be greyed out

QA Steps

Same as test steps

  • 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:
    • iOS / native
    • Android / native
    • iOS / Safari
    • Android / Chrome
    • MacOS / Chrome
    • 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 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 was added in all src/languages/* files
    • I verified any copy / text that was added to the app is correct English and 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 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 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.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
web.mov
Mobile Web - Chrome
chrome.mov
Mobile Web - Safari
safari.mov
Desktop
desktop.mov
iOS
ios.mov
Android
android.mov

@luacmartins luacmartins self-assigned this Dec 7, 2022
@luacmartins luacmartins changed the title Fix split bill flow in App [Hold Web-E #35760] Fix split bill flow in App Dec 8, 2022
@luacmartins luacmartins marked this pull request as ready for review December 9, 2022 00:40
@luacmartins luacmartins requested a review from a team as a code owner December 9, 2022 00:40
@melvin-bot melvin-bot bot requested review from mananjadhav and MonilBhavsar and removed request for a team December 9, 2022 00:41
@melvin-bot
Copy link

melvin-bot bot commented Dec 9, 2022

@mananjadhav @MonilBhavsar 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]

@mananjadhav
Copy link
Collaborator

@luacmartins Can this be reviewed and tested right now? Is it deployed on staging?

@luacmartins
Copy link
Contributor Author

@mananjadhav not yet! I’ll ping you once the API PR is merged!

@mananjadhav
Copy link
Collaborator

Thanks @luacmartins

Copy link
Contributor

@mountiny mountiny left a comment

Choose a reason for hiding this comment

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

Just one NAB, changes look good to me otherwise

src/libs/actions/IOU.js Outdated Show resolved Hide resolved
Comment on lines +490 to 494
function splitBill(participants, currentUserLogin, amount, comment, currency, locale, existingGroupChatReportID = '') {
const {groupData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, amount, comment, currency, locale, existingGroupChatReportID);

API.write('SplitBill', {
reportID: groupData.chatReportID,
Copy link
Contributor

Choose a reason for hiding this comment

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

@luacmartins As Monil pointed out, we are not passing the existingGroupChatReportID to the API here.

Copy link
Contributor

Choose a reason for hiding this comment

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

requesting a change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We actually don't need to pass this param to the API. We have both SplitBill and SplitBillAndOpenReport commands and that's enough for the API to figure out what it needs to do without the need to pass this param.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The front end needs the ID to get the groupChat when it's created from within a chat though

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense!

Comment on lines +490 to 494
function splitBill(participants, currentUserLogin, amount, comment, currency, locale, existingGroupChatReportID = '') {
const {groupData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, amount, comment, currency, locale, existingGroupChatReportID);

API.write('SplitBill', {
reportID: groupData.chatReportID,
Copy link
Contributor

Choose a reason for hiding this comment

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

requesting a change

@luacmartins luacmartins requested a review from mountiny December 9, 2022 15:49
@luacmartins
Copy link
Contributor Author

I fixed the typo. Ready for another review!

Copy link
Contributor

@MonilBhavsar MonilBhavsar left a comment

Choose a reason for hiding this comment

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

Code looks good. I'll get to testing today

@mananjadhav
Copy link
Collaborator

Quick bump is it ready for C+ review and testing?

@luacmartins
Copy link
Contributor Author

@mananjadhav thanks for the bump. Yes, the API changes are in staging already!

@mananjadhav
Copy link
Collaborator

@luacmartins For the offline tests too it should post in the existing group?

Also I am currently testing this flow, but a bit blocked by the mobile web not working.

@mountiny
Copy link
Contributor

a bit blocked by the mobile web not working.

Is this because of the backend issues, right?

For the offline tests too it should post in the existing group?

Yeah I would say the offline should do that same as online if successful

@mananjadhav
Copy link
Collaborator

Yeah none of us are able to run the app web or mobile web unless the IP is whitelisted

@mountiny
Copy link
Contributor

I think it is ok at the current situation to skip the mweb or some internal employee can test those and you test the rest.

@mananjadhav
Copy link
Collaborator

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 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 correct English and 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 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
web-workspace-split-bill.mov
web-split-bill-flow.mov
Mobile Web - Chrome
mweb-chrome-split-bill-1-participant.mov
mweb-chrome-split-bill-participants.mp4
mweb-chrome-workspace-split-bill.mov
Mobile Web - Safari
mweb-safari-split-bill-flow-2-participants.mp4
mweb-safari-split-bill-flow-1-participant.mov
mweb-safari-workspace-split-bill.mov
Desktop
desktop-workspace-split-bill.mov
desktop-split-bill-flow.mov
iOS
ios-split-bill-flow.mov
Android
android-workspace-split-bill.mov
android-split-bill-flow.mov

@mountiny @MonilBhavsar I've tested the mobile web to the best possible means for me. I had a terrible network but it's IP was whitelisted so you can see a lot of lag there. But I managed to test it across all the platforms and have more than one videos for each test.

@luacmartins
Copy link
Contributor Author

Thanks @mananjadhav. Still holding on Web-E.

@luacmartins
Copy link
Contributor Author

Web-E is in prod. Merging this one!

@luacmartins luacmartins changed the title [Hold Web-E #35760] Fix split bill flow in App Fix split bill flow in App Dec 20, 2022
@luacmartins luacmartins merged commit 30e6377 into main Dec 20, 2022
@luacmartins luacmartins deleted the cmartins-fixSplitBillFlow branch December 20, 2022 01:38
@OSBotify
Copy link
Contributor

✋ 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
Copy link
Contributor

Performance Comparison Report 📊

Significant Changes To Duration

Name Duration
TTI 801.137 ms → 852.778 ms (+51.641 ms, +6.4%) 🔴
Show details
Name Duration
TTI Baseline
Mean: 801.137 ms
Stdev: 37.469 ms (4.7%)
Runs: 743.1704550003633 750.0902410000563 755.8597060004249 758.7076340001076 762.4422770002857 765.6524689998478 769.5492209997028 770.7337819999084 772.011435999535 772.6029439996928 776.616004999727 779.5285480003804 782.4146670000628 788.2611100003123 791.0973720001057 796.1605399996042 796.5322380000725 805.1813749996945 805.5671079996973 817.2632870003581 818.5388730000705 820.408118000254 823.4686160003766 829.4891079999506 836.4692869996652 839.5886700004339 841.2591949999332 843.3784330002964 860.177835999988 861.1013289997354 901.9234710000455

Current
Mean: 852.778 ms
Stdev: 47.666 ms (5.6%)
Runs: 758.4708369998261 763.4349929997697 772.1370440004393 777.1020560003817 788.7198310000822 796.2646279996261 821.1173639995977 827.4683509999886 832.9515159996226 833.8107880000025 838.2468299996108 838.7137569999322 841.9088639998809 848.9025140004233 850.5236360002309 851.0061370003968 857.4494129996747 859.8333299998194 874.3102209996432 879.8622479997575 880.926393000409 880.9495710004121 881.6334109995514 890.9833479998633 892.7264550002292 907.316131000407 908.1977599998936 914.7106050001457 918.7966670002788 921.8558390000835 925.7877620002255

Meaningless Changes To Duration

Show entries
Name Duration
runJsBundle 190.419 ms → 201.563 ms (+11.143 ms, +5.9%)
nativeLaunch 9.000 ms → 9.935 ms (+0.935 ms, +10.4%)
regularAppStart 0.017 ms → 0.015 ms (-0.002 ms, -10.4%)
Show details
Name Duration
runJsBundle Baseline
Mean: 190.419 ms
Stdev: 22.721 ms (11.9%)
Runs: 159 162 166 167 168 169 170 170 175 176 180 181 182 183 185 186 186 188 188 189 194 197 198 202 205 215 221 222 230 243 246

Current
Mean: 201.563 ms
Stdev: 25.470 ms (12.6%)
Runs: 161 166 168 177 178 180 182 183 186 187 187 188 189 190 193 193 194 196 203 203 204 204 212 214 221 228 230 232 235 248 255 263
nativeLaunch Baseline
Mean: 9.000 ms
Stdev: 0.802 ms (8.9%)
Runs: 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 11

Current
Mean: 9.935 ms
Stdev: 1.740 ms (17.5%)
Runs: 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 11 11 11 11 12 12 14 14 14
regularAppStart Baseline
Mean: 0.017 ms
Stdev: 0.001 ms (7.4%)
Runs: 0.014852000400424004 0.0148930000141263 0.015176999382674694 0.015177000313997269 0.015300000086426735 0.015339999459683895 0.015422000549733639 0.015544000081717968 0.015625 0.015949999913573265 0.016032000072300434 0.016276000067591667 0.016276000067591667 0.0163569999858737 0.01635799929499626 0.01639800053089857 0.016600999981164932 0.016886000521481037 0.016968000680208206 0.017048999667167664 0.017049000598490238 0.017171000130474567 0.017171000130474567 0.017333999276161194 0.017780999653041363 0.01782300043851137 0.01802500057965517 0.01887999940663576 0.019043000414967537 0.019734999164938927

Current
Mean: 0.015 ms
Stdev: 0.001 ms (5.9%)
Runs: 0.013102000579237938 0.013345999643206596 0.013753000646829605 0.013834000565111637 0.013875000178813934 0.014119000174105167 0.014282000251114368 0.014363999478518963 0.014364000409841537 0.014444999396800995 0.01444500032812357 0.014566999860107899 0.014770999550819397 0.014933999627828598 0.01501499954611063 0.015015000477433205 0.015015000477433205 0.015056000091135502 0.015096000395715237 0.015217999927699566 0.015298999845981598 0.015300000086426735 0.015421999618411064 0.015583999454975128 0.015625 0.015705999918282032 0.0157880000770092 0.015868999995291233 0.01607200037688017 0.0174150001257658

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added the DeployBlockerCash This issue or pull request should block deployment label Dec 20, 2022
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @luacmartins in version: 1.2.42-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by @yuwenmemon in version: 1.2.42-2 🚀

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

@luacmartins luacmartins removed the DeployBlockerCash This issue or pull request should block deployment label Jan 4, 2023
@mallenexpensify mallenexpensify mentioned this pull request Jan 6, 2023
4 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.

5 participants