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

[HOLD issue #34615] Display waypoint error in confirm page and detail page #30621

Closed
wants to merge 33 commits into from

Conversation

dukenv0307
Copy link
Contributor

@dukenv0307 dukenv0307 commented Oct 31, 2023

Details

Display waypoint error in confirm page and detail page

Fixed Issues

$ #29783
PROPOSAL: #29783 (comment)

Tests

  1. Create a distance request with the valid waypoints
  2. Open the distance detail page
  3. Go offline
  4. Click on distance to go to edit page
  5. Edit or add a new waypoint with an invalid address
  6. Save the distance and go online
  7. Verify that the error appears on the detail page
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Create a distance request with the valid waypoints
  2. Open the distance detail page
  3. Go offline
  4. Click on distance to go to edit page
  5. Edit or add a new waypoint with an invalid address
  6. Save the distance and go online
  7. Verify that the error appears on the detail page
  • 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 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 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.

Screenshots/Videos

Android: Native
android-1.mov
Android: mWeb Chrome
chrome.mov
iOS: Native
ios.mov
iOS: mWeb Safari
safari.mov
MacOS: Chrome / Safari
web-1.mov
MacOS: Desktop
desktop-1.mov

@dukenv0307 dukenv0307 marked this pull request as ready for review October 31, 2023 07:29
@dukenv0307 dukenv0307 requested a review from a team as a code owner October 31, 2023 07:29
@melvin-bot melvin-bot bot removed the request for review from a team October 31, 2023 07:29
@melvin-bot
Copy link

melvin-bot bot commented Oct 31, 2023

@aimane-chnaif 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 aimane-chnaif October 31, 2023 07:29
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.

Hey there 👋, I'm jumping in to give an early review.

src/components/ReportActionItem/MoneyRequestView.js Outdated Show resolved Hide resolved
src/libs/ReportUtils.js Outdated Show resolved Hide resolved
src/libs/ReportUtils.js Outdated Show resolved Hide resolved
* @returns {Boolean}
*/
function hasDistanceTransactionRouteErrors(iouReportID) {
const distanceTransactions = getDistanceTransactions(iouReportID);
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be more efficient to check if it's a distance transaction within the some callback, that way we don't have to loop through all transactions once we find one with a route error. Also I think we can just check if it has a route error since only distance transactions can.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same way that we do in hasMissingSmartscanFields function so I think that's fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's update both functions to be more performant. I don't see why we should purposefully do more work than necessary.

We can just do

return _.some(allTransactions, (transaction) => TransactionUtils.hasRouteError(transaction));

src/libs/OptionsListUtils.js Outdated Show resolved Hide resolved
@@ -592,6 +592,7 @@ export default {
genericDeleteFailureMessage: 'Unexpected error deleting the money request, please try again later',
genericEditFailureMessage: 'Unexpected error editing the money request, please try again later',
genericSmartscanFailureMessage: 'Transaction is missing fields',
genericWaypointFailureMessage: 'Distance request has route error',
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you get a copy check for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for asking for a copy check on the issue 🙂

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.

Looking good thanks for the updates. I still want to see a more efficient check for the route error, also waiting on the copy check.

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.

Thank you for the updates! There are still some things to patch up.

src/libs/ReportUtils.js Outdated Show resolved Hide resolved
src/libs/ReportUtils.js Outdated Show resolved Hide resolved
@neil-marcellini
Copy link
Contributor

The copy check is done and it sounds like we can use an error message that already exists in our translation files.

@dukenv0307
Copy link
Contributor Author

Thanks for your feedback, I updated.

@dukenv0307
Copy link
Contributor Author

dukenv0307 commented Nov 3, 2023

@neil-marcellini We don't have a translation like this. And genericWaypointFailureMessage is added for the error of IOU report which has many transactions. That is the reason I added a general message like Distance request has route error.

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.

Your latest updates look good thank you. I tested and I don't see where we display genericWaypointFailureMessage. Do you know if we display it at all? If not we could use the error message from the route directly, in order to check if the report has any errors.

Instead of Please select a valid waypoint, the error message should be Please enter a valid address. That's very close to what was suggested for the copy and we already have a translation key for it.

Finally, I encountered a bug when editing a previously created distance request and adding an invalid address for a stop.

Screen.Recording.2023-11-03.at.11.36.42.AM.mov

@dukenv0307
Copy link
Contributor Author

Instead of Please select a valid waypoint, the error message should be Please enter a valid address. That's very close to what was suggested for the copy and we already have a translation key for it.

I updated.

Finally, I encountered a bug when editing a previously created distance request and adding an invalid address for a stop.

I also saw this bug. I think this came from AddressSearch or Google Autocomplete lib so I think it should be fixed as a separate issue.

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.

We still need to update the error message where it's displayed to use the suggested copy text.

src/libs/OptionsListUtils.js Show resolved Hide resolved
@@ -211,6 +218,8 @@ function MoneyRequestView({report, betas, parentReport, policyCategories, should
shouldShowRightIcon={canEdit && !isSettled}
titleStyle={styles.flex1}
onPress={() => Navigation.navigate(ROUTES.EDIT_REQUEST.getRoute(report.reportID, CONST.EDIT_REQUEST_FIELD.DISTANCE))}
brickRoadIndicator={hasErrors && hasRouteError ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''}
error={hasErrors && hasRouteError ? lodashValues(ErrorUtils.getLatestErrorField(transaction, 'route'))[0] : ''}
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we should show Please enter a valid address

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This display for special request so I think we should display correctly the route error that is returned from BE. We also display this in MoneyRequestConfirmList.

@neil-marcellini
Copy link
Contributor

@dukenv0307 the text shown for the error simply needs to be changed.

Problem

The error message under the distance row is Please select a valid waypoint

Solution

The error message under the distance row should be Please enter a valid address

@dukenv0307
Copy link
Contributor Author

@neil-marcellini Updated.

neil-marcellini
neil-marcellini previously approved these changes Nov 8, 2023
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.

Looks good but there are lint errors @dukenv0307

@dukenv0307
Copy link
Contributor Author

@situchan #30837 was merged. Please help to review again.

@neil-marcellini neil-marcellini changed the title [HOLD 30837] Display waypoint error in confirm page and detail page Display waypoint error in confirm page and detail page Dec 8, 2023
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.

Looks good, pending C+ testing

@situchan
Copy link
Contributor

will complete review by tomorrow

@situchan
Copy link
Contributor

@dukenv0307 please merge main

@dukenv0307
Copy link
Contributor Author

@situchan Updated.

@situchan
Copy link
Contributor

As logic was moved, can you please retest? One platform test is fine

@dukenv0307
Copy link
Contributor Author

dukenv0307 commented Dec 19, 2023

@situchan What do you mean, I moved the logic from old file to the current confirm page now and tested locally.

@situchan
Copy link
Contributor

@situchan What do you mean, I moved the logic from old file to the current confirm page now and tested locally.

yeah I meant that. Logic was moved from old file to new file

@dukenv0307
Copy link
Contributor Author

can you please retest?

@situchan I tested it locally.

@situchan
Copy link
Contributor

@dukenv0307 After online, address is reverted back to valid ones and still shows error

Screenshot 2023-12-19 at 7 06 43 PM

Full repro video:

Screen.Recording.2023-12-19.at.7.04.56.PM.mov

@situchan
Copy link
Contributor

situchan commented Dec 19, 2023

Another bug: Edit distance was closed automatically and Distance field changes to Merchant (seems like report was switched to another one)

Screen.Recording.2023-12-19.at.7.10.01.PM.mov

@dukenv0307
Copy link
Contributor Author

After online, address is reverted back to valid ones and still shows error

@situchan This error is returned from BE since we update waypoint with invalid address.

@dukenv0307
Copy link
Contributor Author

Another bug: Edit distance was closed automatically and Distance field changes to Merchant (seems like report was switched to another one)

@situchan This is out of scope of this issue, because when we offline we generate another transaction thread reportID and with invalid address, when we go back from online this transaction is invalid and it's not stored from BE.

@situchan
Copy link
Contributor

situchan commented Dec 22, 2023

@neil-marcellini what do you think above issues?
I agree out of scope but should we proceed without holding for those fixes?

@neil-marcellini
Copy link
Contributor

@dukenv0307 After online, address is reverted back to valid ones and still shows error

Screenshot 2023-12-19 at 7 06 43 PM Full repro video:
Screen.Recording.2023-12-19.at.7.04.56.PM.mov

This is a bug, but it's related to the issue for handling offline geocoding errors in general. [DISTANCE] LOW: Handle errors with geocoding for offline distance requests. We had a pre-design in Slack a while ago about the desired UX, although it was focused on the creation flow. I think we should follow that plan here too, and we wouldn't get any benefit from merging this until it's implemented as we want it. I hope you're ok with working on this more @dukenv0307.

For this flow here's the desired behavior.

  1. Go offline
  2. View a distance request
  3. Click the distance field
  4. Edit 1 or more waypoints to be invalid
  5. Click save
  6. Expect dependent fields to be pending / TBD
  7. Go online
  8. Dependent fields are still TBD but not pending
  9. The distance transaction chat shows in the LHN with an error indicator
  10. There is a red dot indicator on the distance field
  11. Click the distance field
  12. Error messages are displayed under each invalid waypoint, instructing the user to edit them
  13. When a waypoint is clicked the user can update the address and must use the suggestions which are now shown since they are online
  14. When a new address is saved we clear any errors on the waypoint
  15. Click to save the waypoint edits
  16. Verify that an error message appears instructing the user to edit all invalid waypoints
  17. Do that
  18. Click to save the waypoint edits
  19. Verify that all dependent fields update
  20. Verify all error messages and indicators are cleared

@neil-marcellini
Copy link
Contributor

@dukenv0307 @situchan Thanks for your hard work on this. I know we found some bugs that feel a bit out of scope, but I think we're better off fixing them all at once vs one at a time. That way it's more clear what the desired UX is. Let's use this as our tracking issue [DISTANCE] LOW: Handle errors with geocoding for offline distance requests. I know we'll need some backend changes too, and that issue is currently un-assigned. I hope to pick it up some time after vacation (after January 15).

We could add on to this PR and use it to implement the frontend changes, or just close this and start from scratch later. I would recommend the former however. You might be able to recruit another backend engineer in #wave5-free-submitters to help while I'm out.

@neil-marcellini neil-marcellini marked this pull request as draft December 27, 2023 17:45
@stitesExpensify
Copy link
Contributor

@dukenv0307 @situchan do you know what backend changes @neil-marcellini is referring to? I'd be happy to take them on

@dukenv0307
Copy link
Contributor Author

dukenv0307 commented Feb 20, 2024

I will re-work on this after money request flow is refactored completely. cc @neil-marcellini @situchan.

@dukenv0307 dukenv0307 changed the title Display waypoint error in confirm page and detail page [HOLD issue #34615] Display waypoint error in confirm page and detail page Feb 26, 2024
@neil-marcellini
Copy link
Contributor

This has been handing around for a while, and the backend updates haven't been picked up yet, so going to close this. You can always reopen later.

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