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 for payment 2024-03-29] [MEDIUM] Distance - Unable to save manually entered address after selecting address from list #37640

Closed
6 tasks done
lanitochka17 opened this issue Mar 1, 2024 · 34 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Mar 1, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.46-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4355973
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

Precondition:

  • There are a few addresses in recent destination list
  1. Go to staging.new.expensify.com
  2. Go offline
  3. Go to workspace chat
  4. Open distance request page
  5. Click Start
  6. Select an address from the recent list and save it
  7. Click Start again
  8. Manually enter an address
  9. Save it

Expected Result:

The new address is saved

Actual Result:

The new address is not saved

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6398757_1709324381934.bandicam_2024-03-02_01-20-57-341.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~011597298ea5827798
  • Upwork Job ID: 1763727574947143680
  • Last Price Increase: 2024-03-02
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Mar 1, 2024
Copy link

melvin-bot bot commented Mar 1, 2024

Triggered auto assignment to @greg-schroeder (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave5
CC @dylanexpensify

@lanitochka17
Copy link
Author

@greg-schroeder FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@gijoe0295
Copy link
Contributor

gijoe0295 commented Mar 1, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Distance - Unable to save manually entered address after selecting address from list

What is the root cause of that problem?

We used waypoint${index} as inputID:

inputID={`waypoint${pageIndex}`}

but we retrieved using values.name:

What changes do you think we should make in order to solve the problem?

Change values.name to

values[`waypoint${pageIndex}`]

or name: waypointValue. I think in offline mode, the input address is also its name.

What alternative solutions did you explore? (Optional)

NA

@greg-schroeder greg-schroeder added the External Added to denote the issue can be worked on by a contributor label Mar 2, 2024
@melvin-bot melvin-bot bot changed the title Distance - Unable to save manually entered address after selecting address from list [$500] Distance - Unable to save manually entered address after selecting address from list Mar 2, 2024
Copy link

melvin-bot bot commented Mar 2, 2024

Job added to Upwork: https://www.upwork.com/jobs/~011597298ea5827798

@greg-schroeder greg-schroeder changed the title [$500] Distance - Unable to save manually entered address after selecting address from list [MEDIUM] Distance - Unable to save manually entered address after selecting address from list Mar 2, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Mar 2, 2024
Copy link

melvin-bot bot commented Mar 2, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (External)

@abzokhattab
Copy link
Contributor

abzokhattab commented Mar 2, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Distance - Unable to save manually entered address after selecting address from list

What is the root cause of that problem?

When saving a defined waypoint for the first time, we save an object contains the address and the name to Onyx using the saveWaypoint function. This function merges the old transaction with the new object. The problem arises when we enter an unsaved address while offline because unsaved addresses have the address name as undefined, which causes the old name to remain and not be overwritten in the new selection

What changes do you think we should make in order to solve the problem?

When selecting a waypoint in offline mode, we need to assign an empty string as the fallback value, to ensure that Onyx overrides the old name when it merges with the new object.

so we need to change this:

to

                name: values.name ?? '',

and do the same here
Also we can do the same with the lat, long and the address to make sure that the new object overrides the old one

@bernhardoj
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Can't save an address while offline if there is already a previously selected address while online.

What is the root cause of that problem?

The distance start and stop list shows either the waypoint name or address.

const title = waypoint.name || waypoint.address;

When we first select a suggested waypoint while online, we save both of the waypoint name and address.

const selectWaypoint = (values: Waypoint) => {
const waypoint = {
lat: values.lat,
lng: values.lng,
address: values.address,
name: values.name,
};
Transaction.saveWaypoint(transactionID, pageIndex, waypoint, action === CONST.IOU.ACTION.CREATE);

While offline, we also try to save both waypoint name and address.

const submit = (values: FormOnyxValues<'waypointForm'>) => {
const waypointValue = values[`waypoint${pageIndex}`] ?? '';
// Allows letting you set a waypoint to an empty value
if (waypointValue === '') {
Transaction.removeWaypoint(transaction, pageIndex, true);
}
// While the user is offline, the auto-complete address search will not work
// Therefore, we're going to save the waypoint as just the address, and the lat/long will be filled in on the backend
if (isOffline && waypointValue) {
const waypoint = {
address: waypointValue,
name: values.name,
};
saveWaypoint(waypoint);
}

However, the waypoint name is always undefined because values is an object that contains the form data. The form data of the waypoint has only one input, which is the waypoint address. So, the previous waypoint address is overwritten, but not with the name.

What changes do you think we should make in order to solve the problem?

While offline, we will never be able to get the address name, so to overwrite the previous waypoint name, we can just set null to the name.

name: null,

this was previously fixed in #33692

@5695mp
Copy link

5695mp commented Mar 2, 2024

● Use State to Manage Address:

➢Define a state variable to store the address, let's call it address.
Use the useState hook to manage the address state.

➢Update Address when Manually Entered:
Update the address state when the user manually enters an address.

➢Select Address from List:
When the user selects an address from the list, update the address state with the selected address.

➢Save the Address:
Provide a button or trigger to save the address.
When the save button is pressed, save the address state to your database or storage.

Copy link

melvin-bot bot commented Mar 2, 2024

📣 @5695mp! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@Tony-MK
Copy link
Contributor

Tony-MK commented Mar 2, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Distance - Unable to save manually entered address after selecting an address from the list

What is the root cause of that problem?

In the saveWaypoint function, the onyx only merges the waypoint.address while the previous data of the waypoint persists.

Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {
comment: {
waypoints: {
[`waypoint${index}`]: waypoint,

Therefore, when the user submits the new waypoint, lng, lat, and address will not be nullified but be reused.

// While the user is offline, the auto-complete address search will not work
// Therefore, we're going to save the waypoint as just the address, and the lat/long will be filled in on the backend
if (isOffline && waypointValue) {
const waypoint = {
address: waypointValue,
name: values.name,
};
saveWaypoint(waypoint);

What changes do you think we should make in order to solve the problem?

In the saveWaypoint function, check if lat, lng and name are present in the waypoint to nullify from the transaction's onyx waypoints.

Create a condition after this line as illustrated.

[`waypoint${index}`]: {
  address: waypoint?.address ?? '',
  name: waypoint?.name ?? '',
  lat: waypoint?.lng ?? null,
  lng: waypoint?.lng ?? null,
}

@parasharrajat
Copy link
Member

@abzokhattab's proposal looks good to me.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Mar 2, 2024

Triggered auto assignment to @amyevans, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@Tony-MK
Copy link
Contributor

Tony-MK commented Mar 2, 2024

Hi @parasharrajat, I believe we need remove lat and lng because the waypoint will then get added to recentWaypointAlreadyExists if the condition illustrated below is not satistied.

// You can save offline waypoints without verifying the address (we will geocode it on the backend)
// We're going to prevent saving those addresses in the recent waypoints though since they could be invalid addresses
// However, in the backend once we verify the address, we will save the waypoint in the recent waypoints NVP
if (!lodashHas(waypoint, 'lat') || !lodashHas(waypoint, 'lng')) {
return;

Therefore, if the address is invalid and the GPS coordiantes are present then it will lead to a regression.
Where the invalid address will be suggested as a recent waypoint when editing the request.

@parasharrajat
Copy link
Member

How come the invalid address has GPS coordinates? Does this happen currently in the code?

@abzokhattab
Copy link
Contributor

I see that the invalid address is already not returned as a recent address when online or offline

Screen.Recording.2024-03-04.at.8.21.40.PM.mov

@Tony-MK
Copy link
Contributor

Tony-MK commented Mar 4, 2024

If the address is invalid, the waypoint will still be valid because the GPS coordinates from the previous valid waypoint are sent as a part of the waypoint in the updateMoneyRequestDistance request parameters.

updateMoneyRequestDistance

Since the backend expects the lat and lng to be valid and can not verify the address offline, we have to remove the lat and lng for the backend to instead consider the waypoint as new and unverified.

Notice that the GPS coordinates from the merged modifiedWaypoints are identical to the initial waypoints

1) Initial waypoints before editing waypoint0 offline

Offline

2) Merged modifiedWaypoints after going online

Online

However, removing lat and lng will prevent an invalid address from being considered a valid waypoint.

@amyevans
Copy link
Contributor

amyevans commented Mar 8, 2024

@abzokhattab what's a reasonable ETA to expect a PR?

@melvin-bot melvin-bot bot removed the Overdue label Mar 8, 2024
@abzokhattab
Copy link
Contributor

Should be ready today… thanks amy

@abzokhattab
Copy link
Contributor

Hi team, i just have a small issue with the Upwork offer, the offer you sent cannot be accepted, I get this error:
image

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Mar 22, 2024
@melvin-bot melvin-bot bot changed the title [MEDIUM] Distance - Unable to save manually entered address after selecting address from list [HOLD for payment 2024-03-29] [MEDIUM] Distance - Unable to save manually entered address after selecting address from list Mar 22, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Mar 22, 2024
Copy link

melvin-bot bot commented Mar 22, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Mar 22, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.55-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-03-29. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Mar 22, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@parasharrajat] The PR that introduced the bug has been identified. Link to the PR:
  • [@parasharrajat] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@parasharrajat] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@parasharrajat] Determine if we should create a regression test for this bug.
  • [@parasharrajat] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@greg-schroeder] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added the Overdue label Mar 22, 2024
@greg-schroeder
Copy link
Contributor

Payment pending, not overdue

@parasharrajat
Copy link
Member

parasharrajat commented Mar 25, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

Regression Test Steps

Precondition:
  • There are a few addresses in the recent destination list
  1. Go to staging.new.expensify.com
  2. Go offline
  3. Go to workspace chat
  4. Open distance request page
  5. Click Start
  6. Select an address from the recent list and save it
  7. Click Start again
  8. Manually enter an address
  9. Save it.
  10. Manually entered address should replace the previous saved waypoint.

Do you agree 👍 or 👎 ?

@greg-schroeder
Copy link
Contributor

Processing

@greg-schroeder
Copy link
Contributor

Offer sent @abzokhattab

@greg-schroeder
Copy link
Contributor

@abzokhattab - C - $500
@parasharrajat - C+ - $500 (you can make a ND manual request)

@abzokhattab
Copy link
Contributor

Thank you ... just accepted the offer

@greg-schroeder
Copy link
Contributor

filed regression test, paying, closing

@parasharrajat
Copy link
Member

Payment requested as per #37640 (comment)

@JmillsExpensify
Copy link

$500 approved for @parasharrajat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
No open projects
Development

No branches or pull requests

10 participants