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

#2 - Fix multiple open report call when report screen is mounted #41427

Merged

Conversation

bernhardoj
Copy link
Contributor

@bernhardoj bernhardoj commented May 1, 2024

Details

We call OpenReport in both ReportScreen and ReportActionsView. This PR fix it.

Fixed Issues

$ #41307
$ #39673
PROPOSAL: #39673 (comment)

Tests

Same as QA Steps

  • Verify that no errors appear in the JS console

Offline tests

Same as QA Steps

QA Steps

Web/Desktop

  1. Open developer tools
  2. Switch to the Network tab
  3. Sign out and sign in
  4. Wait until the app load completes
  5. In the network tab, verify there is only 1 OpenReport call and the report chat is shown

Android/iOS/mWeb

  1. Open developer tools (not available in Android/iOS)
  2. Switch to the Network tab
  3. Open any report from LHN
  4. In the network tab, verify there is only 1 OpenReport call and the report chat is shown

Next test for all platforms

  1. Open a thread chat
  2. Press the "From ..." text link
  3. Verify the report screen won't show a blank screen briefly
  4. Open an invalid reportID (such as 123) that you never load before in the device
  5. Verify the skeleton shows and not found view will show after loading completes
  6. Open a valid reportID that you don't have access to
  7. Verify the not found view will show after loading completes
  • 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.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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-05-01.at.23.16.39.mov
Screen.Recording.2024-05-02.at.16.03.40.mov
Screen.Recording.2024-05-03.at.14.59.54.mov
Android: mWeb Chrome
Screen.Recording.2024-05-01.at.22.38.29.mov
Screen.Recording.2024-05-02.at.16.05.32.mov
Screen.Recording.2024-05-03.at.15.06.16.mov
iOS: Native
Screen.Recording.2024-05-01.at.22.44.22.mov
Screen.Recording.2024-05-02.at.16.08.40.mov
Screen.Recording.2024-05-03.at.15.02.43.mov
iOS: mWeb Safari
Screen.Recording.2024-05-01.at.22.25.39.mov
Screen.Recording.2024-05-02.at.16.07.22.mov
Screen.Recording.2024-05-03.at.15.01.17.mov
MacOS: Chrome / Safari
Screen.Recording.2024-05-01.at.19.19.58.mov
Screen.Recording.2024-05-02.at.15.58.35.mov
Screen.Recording.2024-05-03.at.14.58.16.mov
MacOS: Desktop
Screen.Recording.2024-05-01.at.22.17.51.mov
Screen.Recording.2024-05-02.at.16.02.30.mov
Screen.Recording.2024-05-03.at.14.59.12.mov

@bernhardoj bernhardoj requested a review from a team as a code owner May 1, 2024 15:17
@melvin-bot melvin-bot bot requested review from abdulrahuman5196 and removed request for a team May 1, 2024 15:17
Copy link

melvin-bot bot commented May 1, 2024

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

@bernhardoj
Copy link
Contributor Author

The reason #41307 happens is because if the report is loading, we return an empty report actions. Idk why we decide to do that.

const isLoading = (!!reportActionID && isLoadingInitialReportActions) || !isReadyForCommentLinking;

const reportActions = useMemo(() => {
if (!reportActionID) {
return combinedReportActions;
}
if (isLoading || indexOfLinkedAction === -1) {
return [];
}

That's why we don't call OpenReport inside ReportActionsView if we are linking to a message.

useEffect(() => {
if (reportActionID) {
return;
}
const interactionTask = InteractionManager.runAfterInteractions(() => {
openReportIfNecessary();
});

So, I decided to do the same.

Copy link
Contributor

@neil-marcellini neil-marcellini left a comment

Choose a reason for hiding this comment

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

👋 Hi, I'm jumping in to review since this seems valuable. The logic for this area is pretty involved and I don't claim to fully understand it, so I'm asking some questions.

Let's pleas also add a lot more tests, such as opening a link to a message, opening an invalid reportID, opening a valid report link, opening a non-existent report link.

src/pages/home/ReportScreen.tsx Show resolved Hide resolved
src/pages/home/ReportScreen.tsx Show resolved Hide resolved
src/pages/home/report/ReportActionsView.tsx Show resolved Hide resolved
@bernhardoj
Copy link
Contributor Author

Added test for the invalid/non-existing report

Copy link
Contributor

@neil-marcellini neil-marcellini left a comment

Choose a reason for hiding this comment

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

Thanks for your replies. There's still a lot I'm unsure of, so I suggest some more tests to verify the behavior for both yourself and especially us reviewers.

Also please add steps distinguishing between opening an invalid reportID (such as 0), opening a valid report link, and opening a non-existent report link (some random valid id that doesn't exist). "Open an invalid chat" is a bit vague.

@bernhardoj
Copy link
Contributor Author

opening an invalid reportID (such as 0)

Updated the step to be more clear

opening a valid report link,

A valid report link step is already in the test.
image

For the web, after signing in, a valid report will open. In the native test, there is already a step to open any report. I have updated it to "Open any report from LHN" and also to verify the valid report chat is shown to make it more clear.

opening a non-existent report link (some random valid id that doesn't exist)

Added the test step for this.

neil-marcellini
neil-marcellini previously approved these changes May 3, 2024
Copy link
Contributor

@neil-marcellini neil-marcellini left a comment

Choose a reason for hiding this comment

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

Ok, I think it should be good now. I still don't see a test for reportID 0. Leaving it to C+ and the managing engineer for final approvals and merge.

@abdulrahuman5196
Copy link
Contributor

Checking now

@abdulrahuman5196
Copy link
Contributor

@bernhardoj The skeleton view is flickering when moving to a report after sign-in. Could you kindly check on this?

Screen.Recording.2024-05-07.at.5.36.35.PM.mov

@bernhardoj
Copy link
Contributor Author

Thanks for catching that. I found that it happens after we move the fetchReportIfNeeded inside the interaction task. Given that the timing difference is very small, I think we should put it back outside the interaction task. What do you think?

cc: @neil-marcellini

@abdulrahuman5196
Copy link
Contributor

@neil-marcellini Could you kindly check on the above?

@neil-marcellini
Copy link
Contributor

@abdulrahuman5196 I gave a thumbs up, let's put it back outside the interaction task

@bernhardoj
Copy link
Contributor Author

@abdulrahuman5196 updated

@abdulrahuman5196
Copy link
Contributor

Checking now

@abdulrahuman5196
Copy link
Contributor

@bernhardoj I am seeing multiple openReport calls after signin.

Screen.Recording.2024-05-13.at.4.35.45.PM.mp4

@bernhardoj
Copy link
Contributor Author

That's really weird, i can't reproduce that at all.

Screen.Recording.2024-05-13.at.20.53.26.mov

@neil-marcellini
Copy link
Contributor

@abdulrahuman5196 would you please re-test and provide specific test steps if you still experience the bug?

@abdulrahuman5196
Copy link
Contributor

Checking now again

@abdulrahuman5196
Copy link
Contributor

After latest merge I don't see this issue - #41427 (comment)

Finishing checklist.

@abdulrahuman5196
Copy link
Contributor

abdulrahuman5196 commented May 14, 2024

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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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(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 form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • 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

Android: Native
Screen.Recording.2024-05-15.at.12.04.24.AM.mp4
Android: mWeb Chrome
Screen.Recording.2024-05-15.at.12.05.59.AM.mp4
iOS: Native
Screen.Recording.2024-05-14.at.11.57.43.PM.mp4
iOS: mWeb Safari
Screen.Recording.2024-05-15.at.12.02.06.AM.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-05-14.at.11.40.07.PM.mp4
MacOS: Desktop
Screen.Recording.2024-05-14.at.11.44.05.PM.mp4

Copy link
Contributor

@abdulrahuman5196 abdulrahuman5196 left a comment

Choose a reason for hiding this comment

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

Changes looks good and works well. Reviewers checklist is also complete.

All yours. @neil-marcellini / @flodnv

🎀 👀 🎀
C+ Reviewed

@melvin-bot melvin-bot bot requested a review from flodnv May 14, 2024 18:43
@flodnv flodnv merged commit 56ca21c into Expensify:main May 14, 2024
17 checks passed
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/flodnv in version: 1.4.74-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/chiragsalian in version: 1.4.74-6 🚀

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