Skip to content

Show not found for invalid report or transaction in review duplicates confirmation page #45965

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

Merged
merged 17 commits into from
Aug 16, 2024

Conversation

gijoe0295
Copy link
Contributor

@gijoe0295 gijoe0295 commented Jul 22, 2024

Details

Fixed Issues

$ #46179
$ #45835
PROPOSAL: #45835 (comment)

Tests

For Web & mWeb:

  1. Submit 2 duplicated expenses
  2. Press Review duplicates >> Keep this one (any)
  3. Proceed to confirmation page
  4. Modify the report ID in the URL to anything and navigate to it
  5. Verify not found page appears
  • Verify that no errors appear in the JS console

Offline tests

NA

QA Steps

See Tests

  • 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-07-25.at.07.28.40-source.mov
Android: mWeb Chrome
Screen.Recording.2024-07-25.at.07.27.27-source.mov
iOS: Native
iOS: mWeb Safari
Untitled.mov
Screen.Recording.2024-07-25.at.07.31.59-source.mov
MacOS: Chrome / Safari

Screenshot 2024-07-23 at 03 01 32

Screen.Recording.2024-07-25.at.07.08.14-source.mov
MacOS: Desktop

Screenshot 2024-07-23 at 11 42 10

@gijoe0295 gijoe0295 marked this pull request as ready for review July 25, 2024 00:30
@gijoe0295 gijoe0295 requested a review from a team as a code owner July 25, 2024 00:30
@melvin-bot melvin-bot bot removed the request for review from a team July 25, 2024 00:30
Copy link

melvin-bot bot commented Jul 25, 2024

@parasharrajat 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 requested a review from parasharrajat July 25, 2024 00:30
}

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage = isEmptyObject(report) || ReportUtils.isReportNotFound(report) || (!isExiting && status === 'loaded' && !transaction?.transactionID);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When reportID is invalid, report can either be undefined or have errorFields.notFound (on large screens only since the underneath ReportScreen would fetch report data by OpenReport).

REVIEW_DUPLICATES entry takes a long time to load, we need to wait for it by status.

When we close the confirmation page RHP, it would be reset due to:

abandonReviewDuplicateTransactions();

so not found page would briefly show when the RHP is closing. isExiting check was added for that.

Copy link
Member

Choose a reason for hiding this comment

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

I see. Is there a better way to manage the abandonReviewDuplicateTransactions(); without mixing navigation logic on this component? Maybe we delegate this function call when navigation is completed. For example, using transitionEnd event instead of blur if that go hand-in-hand replacement for that.

Copy link
Contributor Author

@gijoe0295 gijoe0295 Jul 31, 2024

Choose a reason for hiding this comment

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

@parasharrajat As you've reviewed the duplicate confirmation PR, could you let me know what these lines are for?

if (
// @ts-expect-error There is something wrong with a types here and it's don't see the params list
navigation.getState().routes.find((routes) => routes.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR)?.params?.screen ===
SCREENS.RIGHT_MODAL.TRANSACTION_DUPLICATE ||
route.params?.screen !== SCREENS.RIGHT_MODAL.TRANSACTION_DUPLICATE
) {
return;
}

In other words, when exactly should abandonReviewDuplicateTransactions be called?

I just want to confirm if transitionEnd could replace blur.

Copy link
Member

@parasharrajat parasharrajat Jul 31, 2024

Choose a reason for hiding this comment

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

This tells that If user is leaving from TRANSACTION_DUPLICATE Modal Stack from RHN view.

Copy link
Contributor Author

@gijoe0295 gijoe0295 Jul 31, 2024

Choose a reason for hiding this comment

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

@parasharrajat transitionEnd does not fire when closing the RHP. Last resort may be setTimeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even if transitionEnd worked, the page would unmount then so we couldn't find it in navigation state.

Copy link
Member

Choose a reason for hiding this comment

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

OK. I am fine with the approach for now.

}, [navigation]);

if (status === 'loading') {
return <FullScreenLoadingIndicator />;
Copy link
Contributor Author

@gijoe0295 gijoe0295 Jul 25, 2024

Choose a reason for hiding this comment

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

Due to the isExiting check as explained above, we should show a loading indicator when the data is loading, otherwise we would have empty data shows briefly.

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

@gijoe0295 There is a comment above.

pecanoro
pecanoro previously approved these changes Jul 30, 2024
Copy link
Contributor

@pecanoro pecanoro left a comment

Choose a reason for hiding this comment

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

Looks good but there are conflicts

@parasharrajat
Copy link
Member

@gijoe0295 There are some conflicts to resolve and I have a comment #45965 (comment).

@gijoe0295
Copy link
Contributor Author

Yeah I knew that. Been investigating since ytd.

@gijoe0295
Copy link
Contributor Author

Updated.

@parasharrajat
Copy link
Member

@gijoe0295 This PR is not solving #45835 properly. It takes some time before the not found page is shown.

01.08.2024_23.50.37_REC.mp4

@gijoe0295
Copy link
Contributor Author

@parasharrajat Solved it.

// eslint-disable-next-line rulesdir/no-negated-variables
const shouldShowNotFoundPage =
isEmptyObject(report) ||
!ReportUtils.isValidReport(report) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When report has been loaded from Onyx but was still loading from the BE, it's prefilled with reportName without reportID.

@gijoe0295
Copy link
Contributor Author

gijoe0295 commented Aug 12, 2024

@parasharrajat I updated. Detailed test steps for this case are:

  1. In thread transaction report, press Review duplicates
  2. Choose the other duplicate transaction that does not belong to the (current) report from step 1

It should not show not found page.

@parasharrajat
Copy link
Member

Now, There is another issue where the confirm page data is shown for a moment while closing.

Steps:

  1. make two sets of duplicates requests.
  2. Open the review duplicate flow for the first set. Go to till Confirm page.
  3. Copy the url.
  4. Now Open the review duplicate flow for the second set and then reach till confirm page.
  5. Close the confirm page.
  6. Now open the copied URL directly from address bar.
  7. Close the confirm page by clicking back area.
  8. Notive the data is shown while page is closing.
13.08.2024_20.05.39_REC.mp4

@gijoe0295
Copy link
Contributor Author

Thanks, taking a look now.

@parasharrajat
Copy link
Member

Please run the test cases from both issues and a couple of edge scenarios before requesting next review.

@dylanexpensify
Copy link
Contributor

@gijoe0295 when can we expect this to be ready for another round of reviews, taking in @parasharrajat's comment above?

@gijoe0295
Copy link
Contributor Author

gijoe0295 commented Aug 14, 2024

@parasharrajat The minimal reproducible steps for your issue are:

  1. Review duplicates till the confirmation page
  2. Replace the reportID in URL with any valid transaction thread report ID (so it contains a valid transaction)
  3. Verify not found page shows (✅ correct)
  4. Close the RHP
  5. Notice the transaction data from step 2 shows briefly ⛔️

Expected behavior: Keep showing not found page ✅

Reason is due to the isExitingPage check here where we do not show not found page if we're CLOSING the RHP.

So root cause leads back to the abandonReviewDuplicateTransactions getting called on blur event. The problem is that blur is triggered right when we close the RHP and the CLOSING transition is on going.

My proposed solution is to forcefully delay that function call by InteractionManager.runAfterInteractions so that it would only be called once the RHP is completely closed (i.e. the closing transition ends). By that we can eliminate isExitingPage check as well.

@gijoe0295
Copy link
Contributor Author

I found another issue that paid expenses are included in review duplicates and if we chose to keep it, we would have not found page:

Screenshot 2024-08-15 at 00 52 57

However, paid expenses should not be there and would be handled in #46372. So NAB.

@parasharrajat
Copy link
Member

Paid expenses will show on this page. That is expected. But we are changing the resolution behavior around them. Anyways, that is a separate issue. Does that affect your changes on this PR?

@parasharrajat
Copy link
Member

Why can't we depend on the isExistingPage as we were doing before?

@gijoe0295
Copy link
Contributor Author

gijoe0295 commented Aug 15, 2024

@parasharrajat

Does that affect your changes on this PR?

Yes it does. The current behavior on main is in #46372. But in this PR, it would show not found page if we press Keep this one on the paid expenses.

Paid expenses will show on this page.

Based on #46372 (comment), are we going to hide Keep this one for paid expenses? If so that wouldn't be a problem.

@gijoe0295
Copy link
Contributor Author

gijoe0295 commented Aug 15, 2024

Why can't we depend on the isExistingPage as we were doing before?

isExitingPage will cause the bug we mentioned in #45965 (comment) and #45965 (comment). Because that makes NotFoundPage disappears when we're EXITING/CLOSING the page.

const shouldShowNotFoundPage = !isExtingPage && ...

@parasharrajat
Copy link
Member

Ok so we used IsExistingPage to prevent `NotFound page from showing on close. Now this is a completely opposite case where we want to remain the notFoundpage if it has to be shown on the main page on closing.

@gijoe0295
Copy link
Contributor Author

@parasharrajat That's correct. But one problem is that abandonReviewDuplicateTransactions still needs to be called when we close the RHP. So I delay that function call by InteractionManager.runAfterInteractions. That makes sure it would only be called once the RHP is completely closed.

@parasharrajat
Copy link
Member

parasharrajat commented Aug 15, 2024

Screenshots

🔲 iOS / native

15.08.2024_20.48.25_REC.mp4

🔲 iOS / Safari

15.08.2024_20.51.04_REC.mp4

🔲 MacOS / Desktop

15.08.2024_20.41.26_REC.mp4

🔲 MacOS / Chrome

15.08.2024_20.38.13_REC.mp4

🔲 Android / Chrome

15.08.2024_21.00.31_REC.mp4

🔲 Android / native

15.08.2024_20.58.40_REC.mp4

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

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.

🎀 👀 🎀 C+ reviewed

@melvin-bot melvin-bot bot requested a review from stitesExpensify August 15, 2024 15:31
@parasharrajat
Copy link
Member

@gijoe0295 Good job on the PR. Thanks for your patience.

@stitesExpensify stitesExpensify merged commit 6fd16ac into Expensify:main Aug 16, 2024
15 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/stitesExpensify in version: 9.0.22-0 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/stitesExpensify in version: 9.0.22-1 🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/chiragsalian in version: 9.0.22-9 🚀

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.

6 participants