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 inbox from briefly displaying when creating WS from selector and … #52092

Conversation

huult
Copy link
Contributor

@huult huult commented Nov 6, 2024

Details

Fixed Issues

$ #50850
PROPOSAL: #50850 (comment)

Tests

Same QA step

  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Open the Expensify app.
  2. Tap the workspace selector icon on the top left.
  3. Tap the "+" icon to add a new workspace.
  4. Complete any required steps to create the workspace.
  5. Verify navigation to the new workspace menu after creation.
  6. Tap the back arrow in the new workspace menu.
  7. Confirm redirection to the workspace selector screen.
  • 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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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 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(theme.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 the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
  • 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.

Screenshots/Videos

Android: Native
Screen.Recording.2024-11-09.at.17.43.58.mp4
Android: mWeb Chrome
Screen.Recording.2024-11-09.at.17.44.37.mp4
iOS: Native
Screen.Recording.2024-11-09.at.17.45.45.mp4
iOS: mWeb Safari
Screen.Recording.2024-11-09.at.17.46.52.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-11-09.at.17.41.03.mp4
MacOS: Desktop
Screen.Recording.2024-11-09.at.17.43.01.mp4

@huult huult requested a review from a team as a code owner November 6, 2024 06:38
@melvin-bot melvin-bot bot requested a review from dominictb November 6, 2024 06:38
Copy link

melvin-bot bot commented Nov 6, 2024

@dominictb 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]

@melvin-bot melvin-bot bot removed the request for review from a team November 6, 2024 06:38
@huult
Copy link
Contributor Author

huult commented Nov 6, 2024

Hi @dominictb, @puneetlath We have an issue after updating the pull request for this ticket, which is:

  • The LHNOptionsList sometimes does not render the full list of data (You can watch the video in this pull request to see the issue I mentioned) after reset to home. This is a separate RCA issue for this ticket and is currently present in production, staging, and the main branch.

Can I ask if we are fixing this issue in this pull request or if a new ticket will be created to address it?

Note: I will set this pull request to WIP until my question is resolved

@huult huult marked this pull request as draft November 6, 2024 06:47
@huult huult marked this pull request as ready for review November 6, 2024 15:34
@puneetlath
Copy link
Contributor

Interesting? What's the reason for that bug?

@huult
Copy link
Contributor Author

huult commented Nov 7, 2024

@puneetlath I feel this issue comes from the lazy load of FlashList. I say this because I logged the data, which is updated, but it doesn't render on the list. I will investigate further

@puneetlath
Copy link
Contributor

Ok, can you look into it? If it's a straightforward change, we can include it hear (and increase the pay). If it's more involved, we can handle separately.

@huult
Copy link
Contributor Author

huult commented Nov 7, 2024

@puneetlath Yes, I am investigating this and will provide you with more details once I find them.

@huult
Copy link
Contributor Author

huult commented Nov 9, 2024

@puneetlath , @dominictb I've updated the fix for the issue mentioned above.

The RCA:

When we tap the plus icon, the orderedReportIDs are updated with the new workspace we created. At that moment, the Flashlist also updates because the list data has changed.

However, we then navigate to the workspace initial screen, so FlashList unmounts, and the LayoutManager inside FlashList sets the height to 0. When we return from the workspace, the data hasn’t changed because it was updated previously, so the height remains 0, and this causes the issue.

This issue happens on mWeb and web. On web, the behavior can appear random, as it depends on the workspace created. If the created workspace has an admin room in the LHN, the issue doesn’t occur because new data is added, including the new reportId of the admin room, causing FlashList to re-render.

The solutions
We should delay navigation until FlashList has finished updating.

If you have any questions, let me know. I can explain further, as I have a deep understanding of why this happened.

@huult
Copy link
Contributor Author

huult commented Nov 12, 2024

@puneetlath @dominictb Can you check my comment?

@dominictb
Copy link
Contributor

Thanks. Reviewing now.

@dominictb
Copy link
Contributor

@huult The bug you are talking about is: LHN just show only 1 item?

resize.mp4

If so can you add the code reference to explain the RCA. For example

However, we then navigate to the workspace initial screen, so FlashList unmounts, and the LayoutManager inside FlashList sets the height to 0

I can't open the LayoutManager reference link.

If the FlashList unmounts, how the component inside it sets the height to 0 (since it unmounts too)

@huult
Copy link
Contributor Author

huult commented Nov 13, 2024

@dominictb

The bug you are talking about is: LHN just show only 1 item?

Yes

I can't open the LayoutManager reference link.

node_modules/recyclerlistview/dist/reactnative/core/layoutmanager/LayoutManager.js here is the path LayoutManager

If the FlashList unmounts, how the component inside it sets the height to 0 (since it unmounts too)

I will provide you with more details tomorrow.
This video shows the height to 0 that I mentioned

Screen.Recording.2024-11-13.at.22.16.48.mp4

@dominictb
Copy link
Contributor

@huult any updates?

@huult
Copy link
Contributor Author

huult commented Nov 14, 2024

@dominictb Please wait for me for 5 more hours

@huult
Copy link
Contributor Author

huult commented Nov 14, 2024

@dominictb I am busy at this time. I will give it as soon as possible, but no later than tomorrow.

@huult
Copy link
Contributor Author

huult commented Nov 15, 2024

@dominictb

If the FlashList unmounts, how the component inside it sets the height to 0 (since it unmounts too)

When tapping the plus icon, the data in FlashList changes, triggering the componentDidUpdate function in node_modules/recyclerlistview/dist/reactnative/core/RecyclerListView.js. Within this function, _checkAndChangeLayouts recalculates the layout (using relayoutFromIndex) when the data changes. That is the logic of FlashList.

Screen.Recording.2024-11-15.at.10.24.47.mov

But when relayoutFromIndex is executed, and we navigate to the workspace, relayoutFromIndex returns a height of 0. We able debug node_modules/recyclerlistview/dist/reactnative/core/layoutmanager/LayoutManager.js to see it. That why, in div set to 0 in this video.

Screen.Recording.2024-11-15.at.10.42.42.mov

And when we go back to the home screen, the height value is still 0. Since the data hasn’t changed, componentDidUpdate is not triggered to re-layout, and this issue occurs.

My suggested solution is to delay navigation to the workspace until the FlashList re-layout is complete. That’s why I used

//src/libs/actions/App.ts#L380
      InteractionManager.runAfterInteractions(() => {
                Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID, backTo));
            });

@dominictb
Copy link
Contributor

Reviewing

@huult
Copy link
Contributor Author

huult commented Nov 19, 2024

@dominictb @puneetlath #52651 is the same RCA we know, and I have found the RCA and have a fix.

@dominictb
Copy link
Contributor

@huult The plus icon to create the new WS is removed in #52623. I think the issue is not reproducible

@huult
Copy link
Contributor Author

huult commented Nov 19, 2024

@dominictb You are correct, if we removed the plus icon, this issue would no longer be valid, and the issue I mentioned would still not be reproducible

@huult
Copy link
Contributor Author

huult commented Nov 19, 2024

@dominictb I think this issue still exists. This is because we have the Get Started case, where if we don't have any workspace, we can create a workspace in the same way. I will double check

@huult
Copy link
Contributor Author

huult commented Nov 19, 2024

@dominictb When we remove the plus icon, we still encounter the 'get started' case for when there is no workspace. So I think we are able to proceed with this pull request to fix this case.

This issue I mentioned:

Screen.Recording.2024-11-19.at.16.11.14.mov

I have already updated the pull request to fix the issue with the 'Get started' case. Can you check it again? Thank you!

@@ -378,7 +378,9 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt(policyOwnerEmail = '', po
Navigation.goBack();
}
savePolicyDraftByNewWorkspace(policyID, policyName, policyOwnerEmail, makeMeAdmin);
Navigation.navigate(ROUTES.WORKSPACE_INITIAL.getRoute(policyID, backTo));
InteractionManager.runAfterInteractions(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the RCA but using runAfterInteractions is not a good idea to me (same as using setTimeout). This bug is also not related to the original one so we can ignore it for now and create another issue for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@puneetlath
Copy link
Contributor

Hi! Just curious for a summary on where we're at with this PR.

@huult
Copy link
Contributor Author

huult commented Nov 26, 2024

As discussed in the ticket, I will close this pull request

@huult huult closed this Nov 26, 2024
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