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

Stop fetching IOU data when a new report action arrives #9836

Merged
merged 5 commits into from
Jul 21, 2022

Conversation

marcaaron
Copy link
Contributor

@marcaaron marcaaron commented Jul 12, 2022

Details

Test with https://github.com/Expensify/Web-Expensify/pull/34278

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/218579

Tests

See QA steps. Test together with https://github.com/Expensify/Web-Expensify/pull/34278

  • Verify that no errors appear in the JS console

PR Review Checklist

Contributor (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 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 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 tagging the marketing team 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
  • 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 */
    • Any functional components have the displayName property
    • 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.

PR Reviewer Checklist

The Contributor+ will copy/paste it into a new comment and complete it after the author checklist is completed

  • 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 verified tests pass on all platforms & I tested again 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 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 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 tagging the marketing team 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 */
    • Any functional components have the displayName property
    • 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 reviewer checklist, including those that don't apply to this PR.

QA Steps

  1. Create a new chat between User A and User B. Note: There should be no pre-existing IOUs on this chat. It should be entirely NEW with no history.
  2. Request money as User A
  3. Verify that the request shows normally in both chats.
  4. Add another request
  5. Verify that the request updates properly and the amount is updated in realtime
  6. Open the IOU Details as User B and decline one of the requests
  7. Verify the amount decreases for both users
  8. Verify message about declining appears for both users
  9. Verify the green and red badge in the chats list still shows there is an amount owed and that the amount is correct.
  10. As User B choose "I'll settle up elsewhere"
  11. Verify the chat updates accordingly and there is no amount owed shown anywhere and all relevant messages appear on the chats.
  • Verify that no errors appear in the JS console

@marcaaron marcaaron self-assigned this Jul 12, 2022
@marcaaron marcaaron changed the title Stop fetching IOU data when a new report action arrives [HOLD Web-E 34278]Stop fetching IOU data when a new report action arrives Jul 12, 2022
@marcaaron marcaaron changed the title [HOLD Web-E 34278]Stop fetching IOU data when a new report action arrives [HOLD Web-E 34278] Stop fetching IOU data when a new report action arrives Jul 19, 2022
@marcaaron marcaaron requested review from mountiny and Julesssss July 19, 2022 20:14
@marcaaron marcaaron marked this pull request as ready for review July 19, 2022 21:48
@marcaaron marcaaron requested a review from a team as a code owner July 19, 2022 21:48
@melvin-bot melvin-bot bot requested review from deetergp and removed request for a team July 19, 2022 21:48
@@ -189,7 +189,6 @@ function getSimplifiedReportObject(report) {
lastMessageTimestamp,
lastMessageText: isLastMessageAttachment ? '[Attachment]' : lastMessageText,
lastActorEmail,
hasOutstandingIOU: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why this is being set here, but it seems wrong.

@@ -1382,9 +1344,8 @@ function syncChatAndIOUReports(chatReport, iouReport) {
}
simplifiedReport[chatReportKey] = getSimplifiedReportObject(chatReport);
simplifiedReport[chatReportKey].hasOutstandingIOU = iouReport.stateNum
=== (CONST.REPORT.STATE_NUM.PROCESSING && iouReport.total !== 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic was wrong and preventing the badge from updating

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.

I am using the mentioned Web-E branch to test with but I am getting a weird behaviour. See the attached video:

Screen.Recording.2022-07-20.at.11.05.13.mov

Basically, when I request multiple times, the details page behaves weird, it shows all of them and then it changes to only show the latest. Additionally, the background report is also changing which should not happen. I am not sure if this is only related to these changes or there could be some influence of the IOUDetailsPage updates we did recently.

Copy link
Contributor

@Julesssss Julesssss left a comment

Choose a reason for hiding this comment

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

This is looking good overall. I noticed the same issue as Vit when testing, but I wonder if this is caused by a separate issue as I think I saw this once when testing my API refactor...

@Julesssss
Copy link
Contributor

So, while copying your IOUReport data structure to fix a separate issue I noticed the exact same bug as we reported above, with the following console error:

Invalid prop `reportActions.8.message` of type `object` supplied to `ReportScreen`, expected an array.

I'm still not exactly sure why, but I think the issue is because an iouReport field is missing from your onyx update data. I'm not sure which field yet, but if you switch to returning $iouReport-> getDeprecatedDataStructure() this issue disappears. Obviously that shouldn't be the solution, as we're still missing hasOutstandingReport & cxhatReportID, but it might help us located the bug.

@Julesssss
Copy link
Contributor

I think this is the problematic line. For the initial render, reportAction.originalMessage exists, but once the new Onyx merge occurs it's null:

Screenshot 2022-07-20 at 17 25 20

@marcaaron
Copy link
Contributor Author

@mountiny @Julesssss thanks for testing!

Can one of you give me the step by step breakdown of what you did to get into that state?

I am going to look at this again now...

@marcaaron
Copy link
Contributor Author

Oh hmm it is very obvious. Weird... I did not see this at all before.

@marcaaron
Copy link
Contributor Author

Yeah @Julesssss I think you're right and it's an issue with the OpenPaymentDetailsPage.

@marcaaron
Copy link
Contributor Author

But it's because of this line:

$reportActions = $chatReport->getActionList()->filterByIOUReportID($iouReportID);

The action list is not the same thing as report "history" so we just bypassed the "report actions" building logic.

@marcaaron
Copy link
Contributor Author

I'll add a change to my other PR - though maybe we should open a new PR with this commit in case that code is headed to staging / production soon?

@marcaaron
Copy link
Contributor Author

@Julesssss
Copy link
Contributor

I'll add a change to my other PR - though maybe we should open a new PR with this commit in case that code is headed to staging / production soon?

Nice. So yeah, I have a WIP PR that resolves a deploy blocker using your report structure. I'll apply the same fix to get this updated ASAP.

However, are you not seeing an exception on this line when opening the PaymentDetailsPage?
Screenshot 2022-07-20 at 18 30 45

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.

Tested with the Web-E Pr and works well!

Just noting that I think the last step in the QA is not correct:

Verify the green and red badge in the chats list still shows there is an amount owed and that the amount is correct.

@marcaaron marcaaron changed the title [HOLD Web-E 34278] Stop fetching IOU data when a new report action arrives Stop fetching IOU data when a new report action arrives Jul 21, 2022
@marcaaron
Copy link
Contributor Author

Off hold now that the Web-E PR is on production 🎉

Copy link
Contributor

@deetergp deetergp 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 and tests well 👍

Screen Shot 2022-07-21 at 2 29 21 PM

Screen Shot 2022-07-21 at 2 29 07 PM

@marcaaron
Copy link
Contributor Author

w00t gonna :shipit:

@marcaaron marcaaron merged commit 574e19d into main Jul 21, 2022
@marcaaron marcaaron deleted the marcaaron-iouReportData branch July 21, 2022 21:51
@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.

@Julesssss
Copy link
Contributor

Umm @deetergp, how did you take those incredible-looking screenshots that perfectly fit the window and include shadows?!

@mountiny
Copy link
Contributor

mountiny commented Jul 22, 2022

@Julesssss When you try to do a normal screenshot(Shift + CMD + 4), instead of selecting the area which to capture, press Spacebar and it will highlight the entire window your cursor is at and when captured it adds the shadow!

@Julesssss
Copy link
Contributor

Thank you, this is much better than manually cropping screens.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @marcaaron in version: 1.1.86-0 🚀

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

@OSBotify
Copy link
Contributor

OSBotify commented Aug 1, 2022

🚀 Deployed to production by @yuwenmemon in version: 1.1.86-5 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 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.

5 participants