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 not found page on thread leave #26602

Merged
merged 7 commits into from
Sep 18, 2023

Conversation

b4s36t4
Copy link
Contributor

@b4s36t4 b4s36t4 commented Sep 3, 2023

Details

Contains fix to show loader when we re-join the thread instead of showing NotFoundPage

Fixed Issues

$ #25698
PROPOSAL: #25698 (comment)

Tests

  • Verify that no errors appear in the JS console
  1. Start a thread
  2. Send some message
  3. Leave the thread
  4. Try opening thread again from main report & should show loader instead of not found page.

Offline tests

  1. Start a thread
  2. Send some messages.
  3. Go to offline
  4. Leave the thread
  5. Try accessing thread again from main report & Should show not found page

QA Steps

  • Verify that no errors appear in the JS console
    Same as Tests section.

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
web.mp4
Mobile Web - Chrome
a-web.mp4
Mobile Web - Safari
ios-web.mp4
Desktop
desktop.mp4
iOS
ios.mp4
Android
android.mp4

@b4s36t4 b4s36t4 requested a review from a team as a code owner September 3, 2023 11:53
@melvin-bot melvin-bot bot removed the request for review from a team September 3, 2023 11:53
@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

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

@mollfpr
Copy link
Contributor

mollfpr commented Sep 4, 2023

Thanks @b4s36t4 I'll do the test ASAP!

@mollfpr
Copy link
Contributor

mollfpr commented Sep 4, 2023

@b4s36t4 I try to leave and open again on the old thread, but I'm getting the not found page. The log results show that the report object has a lastReadTime set. I get this result on the Web and Desktop. Even though it's just resolved itself on the Web, on the Desktop, the result is consistent.

Screen.Recording.2023-09-04.at.23.30.55.mov

It's working well leave the new thread created.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 4, 2023

@mollfpr means this is only happening with old threads? not new thread?

@mollfpr
Copy link
Contributor

mollfpr commented Sep 4, 2023

@b4s36t4 Yes, only on the old thread.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 4, 2023

@mollfpr I'll fix this and update the fix.

@mollfpr
Copy link
Contributor

mollfpr commented Sep 4, 2023

Thanks @b4s36t4 for the quick response 👍

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 6, 2023

Hey, @mollfpr I tried to repro this issue. I haven't been able.

if any workspace is there that have old threads/you're using test account could you share the details?

add me to workspace: maheshvagicherla99438+3@gmail.com

@mollfpr
Copy link
Contributor

mollfpr commented Sep 6, 2023

@b4s36t4 It's not reproduced on a specific thread. Try this step.

  1. Change the connection to 3G slow
  2. Open any thread and leave the thread
  3. Immediately open the thread again

@BhuvaneshPatil
Copy link
Contributor

BhuvaneshPatil commented Sep 6, 2023

I think better approach is to add, withReportOrNotFound HOC to ReportScreen it will show loading screen as well.
@b4s36t4 Try this one and see if it works.

And with this approach you won't need to change shouldShow condition as well.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 6, 2023

No @BhuvaneshPatil I don't think so. We have different logic here.

const shouldShowNotFoundPage = _.isEmpty(props.report) || !props.report.reportID || !ReportUtils.canAccessReport(props.report, props.policies, props.betas);
if the report is empty we show notfound page.. which is not the behaviour we need.

Not Relavent
And this shouldShowFullScreenLoadingIndicator is only happens

isLoadingReportActions: true,
this true which is not gonna work everytime.

And I don't wanna change the wrapper component, because it might cause more issues.

@BhuvaneshPatil
Copy link
Contributor

okay

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 6, 2023

@mollfpr I had to update the logic inside the report to show loader correctly.

Reasons for logic update

  1. When in slow network, because of optimistic data, report data have statusNum and stateNum properties. If we have optimistic delete we don't have to show loader or notfound page we can still show the report. We can update the logic here. Although this might can raise few issues.

  2. After leaving the thread, we show loader with having condition for optimistic delete as well, but due the props update for a moment we're not passing props.report to ReportScreen component which results in default report prop we have defined which causes to show NotFoundPage for a single moment.

Issues*
If we leave thread while in offline, with the current logic we still show the report using this use can still send messages. This can be a future issue.

Would love to take your thoughts on this.

@mollfpr
Copy link
Contributor

mollfpr commented Sep 8, 2023

@b4s36t4 I'm okay with number 2, and for number 1, the issues seem unacceptable.

My understanding is the issue here is because of the default props for the report and the optimistic value for stateNum and statusNum. Can we omit the key?

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 8, 2023

@mollfpr Omit in the sense? Sorry I'm not able to understand your suggestion. You're suggesting that we check for emptiness of a report by omiting those two keys? so that we show loader even if the leaving thread done in offline?

@mollfpr
Copy link
Contributor

mollfpr commented Sep 8, 2023

so that we show loader even if the leaving thread done in offline?

Sorry, I understand the issue now. Omitting the key won't fix the loading issue.

If we leave thread while in offline, with the current logic we still show the report using this use can still send messages. This can be a future issue.

Does this issue exist in the last commit?

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 8, 2023

Does this issue exist in the last commit?

Yes, this is because of checks I have added in last commit.

@mollfpr
Copy link
Contributor

mollfpr commented Sep 8, 2023

We should eliminate that issue. I think sending a message on the left thread will make the user join the thread again.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 8, 2023

Right the only issue I see is how we're going to handle the issue in offline scenario, if user leaves a thread while in offline we show loading page, not-found page? since they haven't left the thread yet because of offline let them use the thread just as they do?

Tagging @trjExpensify for the expected behaviour.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 8, 2023

So, let's show the loader at any case if the user leaves is the expected behaviour right? @mollfpr

@mollfpr
Copy link
Contributor

mollfpr commented Sep 8, 2023

Do you mean showing the loader while the waiting for the API response?

@mollfpr
Copy link
Contributor

mollfpr commented Sep 10, 2023

This is my question, let me know if you understand this (sorry if you don't, sorry for my english and explanation skills 😅)

No worries 👍

Here's what I'm thinking about the expected behavior:

  • The user should see NotFoundPage on leaving the thread ONLINE or OFFLINE
  • The user should see the skeleton loader when revisiting the thread again on ONLINE, and will see the NotFoundPage on OFFLINE
  • In another case, if the report is not available from the BE, then the user will see the skeleton loader until the API resolves and see the NotFoundPage afterward

Let me know if this make sense to you.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 11, 2023

The user should see NotFoundPage on leaving the thread ONLINE or OFFLINE

@mollfpr should see NotFoundPage?? or should not?

@mollfpr
Copy link
Contributor

mollfpr commented Sep 11, 2023

@b4s36t4 Should see the NotFoundPage.

@trjExpensify
Copy link
Contributor

The user should see NotFoundPage on leaving the thread ONLINE or OFFLINE

Hm, but why? I think we want to avoid a "hmm.. this page can't be found" error screen when you leave a thread.

The user should see the skeleton loader when revisiting the thread again on ONLINE, and will see the NotFoundPage on OFFLINE

Why the NotFoundPage when revisting a thread offline?

In another case, if the report is not available from the BE, then the user will see the skeleton loader until the API resolves and see the NotFoundPage afterward

When it resolves, why would they see the NotFoundPage instead of the actual contents of the thread?

CC: @chiragsalian would be good to consult here on this behaviour in and around threads.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 11, 2023

Screenshot 2023-09-11 at 8 46 34 PM

@trjExpensify These are the concluded points we've talked on 1:1

@mollfpr
Copy link
Contributor

mollfpr commented Sep 11, 2023

Hm, but why? I think we want to avoid a "hmm.. this page can't be found" error screen when you leave a thread.

When it resolves, why would they see the NotFoundPage instead of the actual contents of the thread?

We will not see the not found page online because we will show the skeleton loader once we get the result from the API. It's either the report found, and we will show the content, or the report is not available from the BE then the not found page will be shown.

Why the NotFoundPage when revisting a thread offline?

We already have this, and the original issue is off from offline flow. Although it makes sense to show the skeleton loader here, it's out of scope from the original issue, and I'm not sure how the effort for @ b4s36t4 is.

But it's better to decide here and what the next move should be.

@trjExpensify
Copy link
Contributor

If a page isn't available from the backend because you're offline, then we should more accurately show the "full page blocking" offline message to explain that's because you're offline, and that you need to come back online to view the contents of the page. That's the appropriate offline "pattern D" handling, isn't it? It's more informative and accurate than effectively communicating something is broken with "Hmm.. this page isn't here" just because you're offline.

@chiragsalian
Copy link
Contributor

I'm not entirely sure what the questions are for me. Plus @luacmartins might be able to answer as well since its more specific to money requests.

As for my thoughts,

Should see the NotFoundPage.

I disagree with this. Why show the NotFoundPage when clicking a thread online or offline. The user should have access to view this page and if its a loading delay i would rather just show a loading screen like we do when we click into regular threads while offline. (its perhaps not the best offline experience but i'd like to keep it consistent between money requests and threads so that if one day we update them then both are updated). If we still like to have NotFoundPage maybe explain to me why since i could be missing some context.

Also when leaving a thread we should navigate to parent report or another report instead of showing NotFoundPage imo.

We will not see the not found page online because we will show the skeleton loader once we get the result from the API

That doesn't sound right, for regular threads don't we show skeleton loader the moment we click into a thread even when offline?

Although it makes sense to show the skeleton loader here..

Yeah i agree with this.

it's out of scope from the original issue, and I'm not sure how the effort for

I would prefer revisiting this and figuring out its effort to keep the functionality here similar to regular threads.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 11, 2023

Kapture.2023-09-11.at.18.29.56.mp4

I'm uploading the video with the current behaviour i.e in my local. This video give more clarity for people.

cc: @mollfpr @trjExpensify @chiragsalian

@chiragsalian
Copy link
Contributor

From the video the online experience looks good to me. The offline looks incorrect. I'm not a fan of showing "Hmm, its not there" since that is misleading.
I would prefer we either show the loading screen (which is what we show when offline and we click into a thread the first time, i.e., before leaving it), or build something new and better.
For now i would recommend the former, i.e., showing the loading screen when clicked into the thread.
Because the latter would be a much more involved change and we would have to loop in design and have a discussion around it, for which now doesn't feel like the best time for it imo.

@trjExpensify
Copy link
Contributor

I would prefer we either show the loading screen (which is what we show when offline and we click into a thread the first time, i.e., before leaving it), or build something new and better.
For now i would recommend the former, i.e., showing the loading screen when clicked into the thread.
Because the latter would be a much more involved change and we would have to loop in design and have a discussion around it, for which now doesn't feel like the best time for it imo.

Yes, I think it's either the skeleton UI in this case or, we use the established Pattern D "You appear to be offline" error screen which would be more discerning and informative.

@mollfpr
Copy link
Contributor

mollfpr commented Sep 12, 2023

For now i would recommend the former, i.e., showing the loading screen when clicked into the thread.
Because the latter would be a much more involved change and we would have to loop in design and have a discussion around it, for which now doesn't feel like the best time for it imo.

@trjExpensify Currently we are showing the skeleton loader while visiting the existing report, but the content is not yet saved in Onyx. So I think skeleton loader it is?

@b4s36t4 Does change the offline behavior complicate this PR?

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 12, 2023

I have updated the pr, but wouldn't take much time. So if I visit the thread either in offline or online we should show loader.

Depends on api response the screen would result either in report or not found page right?

@mollfpr
Copy link
Contributor

mollfpr commented Sep 12, 2023

I have updated the pr, but wouldn't take much time. So if I visit the thread either in offline or online we should show loader.

Yes, only when there's no report exists with that reportID in the Onyx.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 12, 2023

Ok, Sure got it. Will update the PR soon.

@b4s36t4
Copy link
Contributor Author

b4s36t4 commented Sep 14, 2023

https://github.com/Expensify/App/assets/590889354c16ad-e11b-4c65-a2bf-93217287ca75

@mollfpr I have updated the code here's an example screen-recording of the behaviour of application (no change is done same screen-recordings that I attached first are good)

@mollfpr
Copy link
Contributor

mollfpr commented Sep 17, 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
26602.Web.mp4
Mobile Web - Chrome
26602.mWeb-Chrome.mp4
Mobile Web - Safari
26602.mWeb-Safari.mp4
Desktop
26602.Desktop.mp4
iOS
26602.iOS.mp4
Android
26602.Android.mp4

Copy link
Contributor

@mollfpr mollfpr left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@luacmartins luacmartins merged commit 9b56a76 into Expensify:main Sep 18, 2023
12 checks passed
@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.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/luacmartins in version: 1.3.71-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/thienlnam in version: 1.3.71-12 🚀

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.

7 participants