App icon indicating copy to clipboard operation
App copied to clipboard

fix/14490: No data displayed in options list if component using report data is rendered too early

Open jczekalski opened this issue 1 year ago • 28 comments

Details

The issue affects components that rely on report and personal details data to display a list of options. If the component is rendered too early, the data will not be displayed even when it has fully loaded. This issue was originally identified on SearchPage, where, if the page is opened too early, the data would only be displayed after closing and re-opening the page or typing in the input field.

Pages/components affected by this problem:

  • SearchPage
  • NewChatPage / NewGroupPage
  • IOUParticipantsRequest
  • IOUParticipantsSplit

The purpose of this PR is to:

  • make sure the UI updates when report / personal details data is available
  • display a skeleton loading state for all options lists while data is loading

Fixed Issues

$ https://github.com/Expensify/App/issues/14490 $ https://github.com/Expensify/App/issues/17293 $ https://github.com/Expensify/App/issues/16739 PROPOSAL: https://github.com/Expensify/App/issues/14490#issuecomment-1503720075

Tests

  1. Open the app
  2. Set network throttling to Slow 3G or slower
  3. Open one of the pages affected by the problem as soon as the app loads
  • Search Page (Cmd + K)
  • New Chat Page / New Group Page
  • Send Money / Request Money / Split Bill -> enter amount -> tap Next
  1. The options list should display a skeleton loading state
  2. Data should replace the loading state once available
  3. If search term is entered while data is loading, it should be applied once data is displayed
  • [x] Verify that no errors appear in the JS console

Offline tests

Web

To make it easier to reproduce this issue, set network throttling to Slow 3G or add an even slower profile, e.g. image

Mac

Simulate a bad network using Network Link Conditioner image

QA Steps

  1. Open the app
  2. Set network throttling to Slow 3G or slower
  3. Open one of the pages affected by the problem as soon as the app loads
  • Search Page (Cmd + K)
  • New Chat Page / New Group Page
  • Send Money / Request Money / Split Bill -> enter amount -> tap Next
  1. The options list should display a skeleton loading state
  2. Data should replace the loading state once available
  3. If search term is entered while data is loading, it should be applied once data is displayed
  • [x] Verify that no errors appear in the JS console

PR Author Checklist

  • [x] I linked the correct issue in the ### Fixed Issues section above
  • [x] I wrote clear testing steps that cover the changes made in this PR
    • [x] I added steps for local testing in the Tests section
    • [x] I added steps for the expected offline behavior in the Offline steps section
    • [x] I added steps for Staging and/or Production testing in the QA steps section
    • [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • [x] 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)
    • [x] 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).
  • [x] I included screenshots or videos for tests on all platforms
  • [x] I ran the tests on all platforms & verified they passed on:
    • [x] Android / native
    • [x] Android / Chrome
    • [x] iOS / native
    • [x] iOS / Safari
    • [x] MacOS / Chrome / Safari
    • [x] MacOS / Desktop
  • [x] 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)
  • [x] I followed proper code patterns (see Reviewing the code)
    • [x] 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)
    • [x] I verified that comments were added to code that is not self explanatory
    • [x] 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.
    • [x] I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • [x] 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:
    • [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • [x] 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.
    • [x] 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.
    • [x] I verified the JSDocs style guidelines (in STYLE.md) were followed
  • [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • [x] I followed the guidelines as stated in the Review Guidelines
  • [x] 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)
  • [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • [x] 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
  • [x] I verified that if a function's arguments changed that all usages have also been updated correctly
  • [x] If a new component is created I verified that:
    • [x] A similar component doesn't exist in the codebase
    • [x] All props are defined accurately and each prop has a /** comment above it */
    • [x] The file is named correctly
    • [x] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • [x] The only data being stored in the state is data necessary for rendering and nothing else
    • [x] 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)
    • [x] 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)
    • [x] All JSX used for rendering exists in the render method
    • [x] 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
  • [x] If any new file was added I verified that:
    • [x] 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
  • [x] If a new CSS style is added I verified that:
    • [x] A similar style doesn't already exist
    • [x] The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • [x] 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.
  • [x] 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)
  • [x] 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.
  • [x] 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.
  • [x] 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.
  • [x] I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web Skeleton loader - Search Page (no search term)

https://user-images.githubusercontent.com/39824924/231226897-204bee35-cdae-4009-bf4e-a63ef8944df6.mov

Skeleton loader - New Chat (with search term entered while loading)

https://user-images.githubusercontent.com/39824924/231226929-8e08a7ec-d20d-4615-a1fd-cc4f86b6fa62.mov

Skeleton loader - Send Money

https://user-images.githubusercontent.com/39824924/231227022-e8e9a13e-ed33-4a68-aadb-8ea2ee582044.mov

Report and personal details data updating

https://user-images.githubusercontent.com/39824924/233602240-c8057c51-ae43-4641-8905-9f9abb49cf9e.mov

Mobile Web - Chrome

https://user-images.githubusercontent.com/39824924/231726569-f9078f6e-e5e5-4fb6-bb6f-48bc246dffeb.mov

Mobile Web - Safari

https://user-images.githubusercontent.com/39824924/231708839-0b523568-670f-4b63-811a-0ca5eaa96250.mov

Desktop

https://user-images.githubusercontent.com/39824924/231693221-3a1fde00-38c1-4902-aa00-39119c99c3ce.mov

iOS

https://user-images.githubusercontent.com/39824924/231708749-a1cee374-b841-445c-88be-e0dd5b232090.mov

Android

https://user-images.githubusercontent.com/39824924/231726517-e9060cee-3cb1-4143-ae25-dfcb855999b9.mov

jczekalski avatar Apr 12 '23 16:04 jczekalski

@amyevans @aimane-chnaif 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]

MelvinBot avatar Apr 12 '23 16:04 MelvinBot

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Apr 12 '23 16:04 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

jczekalski avatar Apr 12 '23 16:04 jczekalski

recheck

jczekalski avatar Apr 12 '23 17:04 jczekalski

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@jczekalski no worries. as bot says, you signed already.

aimane-chnaif avatar Apr 12 '23 17:04 aimane-chnaif

PR is ready for review @aimane-chnaif @amyevans

jczekalski avatar Apr 13 '23 10:04 jczekalski

@jczekalski don't use rebase merge. too many commits and irrelevant code changes. can you repair PR?

aimane-chnaif avatar Apr 14 '23 11:04 aimane-chnaif

@jczekalski don't use rebase merge. too many commits and irrelevant code changes. can you repair PR?

@aimane-chnaif Yes, sorry, I tried to update my branch with main since some conflicts showed up and I messed it up.

jczekalski avatar Apr 14 '23 11:04 jczekalski

@aimane-chnaif Fixed

jczekalski avatar Apr 14 '23 13:04 jczekalski

@jczekalski please pull from main

aimane-chnaif avatar Apr 18 '23 13:04 aimane-chnaif

@jczekalski please pull from main

@aimane-chnaif done

jczekalski avatar Apr 19 '23 10:04 jczekalski

@aimane-chnaif will you be able to review/test today?

amyevans avatar Apr 19 '23 13:04 amyevans

@aimane-chnaif will you be able to review/test today?

yes

aimane-chnaif avatar Apr 19 '23 13:04 aimane-chnaif

@jczekalski Did you push all the changes? I don't think PR fixes main bugs happening on search, money request pages. Showing skeleton forever, app crashes very often

https://user-images.githubusercontent.com/96077027/233257777-db70f0f1-d7b8-4280-b260-342fbe2adf8f.mov

https://user-images.githubusercontent.com/96077027/233257807-4a1f81d9-e7b9-41e3-925f-0694806d1126.mov

https://user-images.githubusercontent.com/96077027/233257817-3d1ad07b-28f9-4536-9c54-daec0a4ecf24.mov

aimane-chnaif avatar Apr 20 '23 04:04 aimane-chnaif

Also please pull from main and fix conflicts

aimane-chnaif avatar Apr 20 '23 04:04 aimane-chnaif

Also let's make sure that our PR fixes https://github.com/Expensify/App/issues/17293, https://github.com/Expensify/App/issues/16739 which were closed in favor of our issue. So please follow their reproducible steps and fix them. The root cause and solution is well explained here.

aimane-chnaif avatar Apr 20 '23 04:04 aimane-chnaif

@jczekalski Did you push all the changes? I don't think PR fixes main bugs happening on search, money request pages. Showing skeleton forever, app crashes very often

bug1.mov bug2.mov bug3.mov

@aimane-chnaif You're right, it's not working for me either. Something must have changed since I originally opened the PR, I'll try to figure out what's going on.

jczekalski avatar Apr 20 '23 08:04 jczekalski

Also let's make sure that our PR fixes #17293, #16739 which were closed in favor of our issue. So please follow their reproducible steps and fix them. The root cause and solution is well explained here.

I'm not familiar with those issues, I'll take a look.

jczekalski avatar Apr 20 '23 08:04 jczekalski

@aimane-chnaif I pulled in the changes from the latest version of main and everything is working correctly again.

jczekalski avatar Apr 20 '23 10:04 jczekalski

Let's fix https://github.com/Expensify/App/issues/16739

https://user-images.githubusercontent.com/96077027/233346385-2ace95fc-77ff-4b1e-8dc0-cc1a60303c4d.mov

aimane-chnaif avatar Apr 20 '23 10:04 aimane-chnaif

Let's fix https://github.com/Expensify/App/issues/17293

https://user-images.githubusercontent.com/96077027/233346598-1c6aceb8-6d45-4116-9700-033283e352f7.mov

aimane-chnaif avatar Apr 20 '23 11:04 aimane-chnaif

Let's fix #16739

bug4.mov

@aimane-chnaif I can't reproduce this issue on my branch, even with an incredibly slow connection.

https://user-images.githubusercontent.com/39824924/233350347-05f57472-b5f5-4532-8e24-5d84ba35df60.mov

jczekalski avatar Apr 20 '23 11:04 jczekalski

I can't reproduce this issue on my branch, even with an incredibly slow connection.

It's not constantly reproducible. The reason is explained here. As I stated in proposal review, we should prevent calling getNewChatOptions, getSearchOptions before personalDetails data is loaded.

aimane-chnaif avatar Apr 20 '23 11:04 aimane-chnaif

I can't reproduce this issue on my branch, even with an incredibly slow connection.

It's not constantly reproducible. The reason is explained here. As I stated in proposal review, we should prevent calling getNewChatOptions, getSearchOptions before personalDetails data is loaded.

@aimane-chnaif Ready for review. I think all of the issues should be fixed now.

17293:

https://user-images.githubusercontent.com/39824924/233400325-a6d2933e-bb8a-4f42-bb72-54d772d77bf0.mov

16739:

https://user-images.githubusercontent.com/39824924/233400361-6596cb25-adea-40fe-afda-38cfb2947f79.mov

This change should prevent the issue described here, i.e. make sure personal details data is ready before trying to create list options. Let me know what you think.

jczekalski avatar Apr 20 '23 14:04 jczekalski

@aimane-chnaif @amyevans PR is ready for review. It should fix all of these issues: https://github.com/Expensify/App/issues/14490, https://github.com/Expensify/App/issues/17293, https://github.com/Expensify/App/issues/16739. I added all of them to the list of Fixed Issues in the description.

jczekalski avatar Apr 21 '23 11:04 jczekalski

@aimane-chnaif I see you added the 👀 emoji above but I'm not sure when you added it 😅. Will you be able to put this PR through its paces today?

amyevans avatar Apr 26 '23 14:04 amyevans

yes, in review. will post updates today

aimane-chnaif avatar Apr 26 '23 14:04 aimane-chnaif

@aimane-chnaif Any updates? Did you get a chance to review the changes?

jczekalski avatar Apr 27 '23 09:04 jczekalski

@amyevans can you please confirm if following pages should also be fixed here? Workspace members, Settings Right now, Workspace members page crashes, Settings page shows blank when go to those pages directly before loading reports, personal details

https://user-images.githubusercontent.com/96077027/234954245-ebc927f0-a3ea-434d-836c-2692ccfd09a0.mov

https://user-images.githubusercontent.com/96077027/234954298-57d5b116-468c-4ae7-a75a-7506e403bd95.mov

aimane-chnaif avatar Apr 27 '23 18:04 aimane-chnaif

This change should prevent the issue described https://github.com/Expensify/App/issues/16739#issuecomment-1498682840, i.e. make sure personal details data is ready before trying to create list options. Let me know what you think.

@jczekalski I am fine with this change but just this concern: If reports data is loaded before personalDetails, what do we show? Skeleton depends on reports data loading and options list depends on personalDetails. So this case, empty list shows briefly until getting personalDetails. Most likely won't happen but we should handle this edge case as well.

@amyevans in this case, what do you suggest? still show skeleton or leave as is for now as empty list?

aimane-chnaif avatar Apr 27 '23 18:04 aimane-chnaif