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 2023-12-28] [$500] Distance - Map, amount and distance in the background shows TBD when editing distance #32120

Closed
2 of 6 tasks
kbecciv opened this issue Nov 28, 2023 · 40 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@kbecciv
Copy link

kbecciv commented Nov 28, 2023

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.4.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:
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:

  1. Navigate to staging.new.expensify.com
  2. Go to a workspace chat with distance request.
  3. Open distance request details page.
  4. Click Distance.
  5. Click Add stop.
  6. Add a new address.

Expected Result:

The map, amount and distance in the background will not show TBD because user is editing the distance without saving.

Actual Result:

The map, amount and distance in the background shows TBD without saving.

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

Bug6293218_1701178732509.20231128_134639.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01c7d894fb538d33ef
  • Upwork Job ID: 1729498349642403840
  • Last Price Increase: 2023-12-12
  • Automatic offers:
    • ntdiary | Reviewer | 28055126
    • DylanDylann | Contributor | 28055129
@kbecciv kbecciv added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Nov 28, 2023
@melvin-bot melvin-bot bot changed the title Distance - Map, amount and distance in the background shows TBD when editing distance [$500] Distance - Map, amount and distance in the background shows TBD when editing distance Nov 28, 2023
Copy link

melvin-bot bot commented Nov 28, 2023

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

Copy link

melvin-bot bot commented Nov 28, 2023

Job added to Upwork: https://www.upwork.com/jobs/~01c7d894fb538d33ef

Copy link

melvin-bot bot commented Nov 28, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 28, 2023
Copy link

melvin-bot bot commented Nov 28, 2023

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

@DylanDylann
Copy link
Contributor

DylanDylann commented Nov 28, 2023

Proposal

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

Distance - Map, amount and distance in the background shows TBD when editing distance

What is the root cause of that problem?

When selecting a new stop waypoint we will set pendingField.waypoint is updated and we only reset it to null if user click save button. We are displaying TBD in the amount field if there is a pending waypoint.

const hasPendingWaypoints = lodashGet(transaction, 'pendingFields.waypoints', null);

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

We should update condition here

const hasPendingWaypoints = lodashGet(transaction, 'pendingFields.waypoints', null);

like that

    const hasPendingWaypointsAndOffline = lodashGet(transaction, 'pendingFields.waypoints', null) && isOffline;

And using it instead of hasPendingWaypoints in everywhere.

What alternative solutions did you explore? (Optional)

I am not sure why we need to set pendingField.waypoint when selecting a new waypoint

pendingFields: {

Even though we don't call API in here. Normally, pendingField and pending action only be added in optimisticaData (apply before sending API) and It is re-set in successData and failureData
So I think we should not set pendingField.waypoint when the user updates a new waypoint, we only set the pending field if the user clicks save button

@shubham1206agra
Copy link
Contributor

shubham1206agra commented Nov 28, 2023

Proposal

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

Distance - Map, amount and distance in the background shows TBD when editing distance

What is the root cause of that problem?

This is because we are editing directly on transaction Onyx. And we are using backup in transactionDraft_ collection for saving the last transaction.

Due to changes in transactions directly, the fields are getting TBD due to hasPendingWaypoints becomes true when adding waypoint.

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

We can do the opposite. Use Transaction Draft for editing and then transfer the updated data on transaction collection later.

What alternative solutions did you explore? (Optional)

@paultsimura
Copy link
Contributor

paultsimura commented Nov 28, 2023

Proposal

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

When editing a Distance request, the distance and amount fields are set to "TBD" before the actual update happens.

What is the root cause of that problem?

We are not handling the loading state of the distance transaction properly.
On the MoneyRequestView page, we use:

const hasPendingWaypoints = lodashGet(transaction, 'pendingFields.waypoints', null);

Which equals true when we have modified the waypoints in the drawer, but have not saved them yet.

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

We set the transaction.isLoading when modifying the waypoints of the distance request here:

App/src/libs/actions/IOU.js

Lines 757 to 766 in cd9cd57

optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: {
...updatedTransaction,
pendingFields,
isLoading: _.has(transactionChanges, 'waypoints'),
errorFields: null,
},
});

And we handle this state in other places, like here:

const isLoading = lodashGet(transaction, 'isLoading', false);

First, on MoneyRequestView, we should also replace the hasPendingWaypoints with isLoading along with isOffline, and use it in places where hasPendingWaypoints is currently used:

const isLoading = lodashGet(transaction, 'isLoading', false) && isOffline;

Second, we should also use if (!transaction.isLoading) instead of if (!Object.hasOwn(transaction?.pendingFields ?? {}, 'waypoints')) here, otherwise the map will be replaced with the pending receipt while the waypoints are being added.

if (!Object.hasOwn(transaction?.pendingFields ?? {}, 'waypoints')) {

Basically, we will need to modify most of the changes made in PR #30232 using this condition.

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Dec 1, 2023
@adelekennedy
Copy link

@ntdiary a few proposals to review above!

@melvin-bot melvin-bot bot removed the Overdue label Dec 1, 2023
@ntdiary
Copy link
Contributor

ntdiary commented Dec 4, 2023

under review

@ntdiary
Copy link
Contributor

ntdiary commented Dec 5, 2023

For @DylanDylann's proposal, isOffline does not work when editing waypoints offline.

For @shubham1206agra's proposal, the changes made using the draft for editing might be substantial, but the benefits gained are relatively small, as currently we only need to show TBD after clicking save and before the request is complete.

So far, I think the fitting approach is to check the transaction.isLoading field (i.e., @paultsimura's proposal), but there are still some details that need optimization, and if necessary, we may need to refactor the changes in PR #30232 using this condition.

@paultsimura
Copy link
Contributor

paultsimura commented Dec 5, 2023

we may need to refactor the changes in PR #30232 using this condition

I was initially oriented on the changes of this PR when posting my proposal. Just didn't want to clutter the proposal with all the changes, but yes, we'll need to make changes in all the places where PR #30232 used pending waypoints.

Added this sentence into the proposal now.

@DylanDylann
Copy link
Contributor

@ntdiary What about my alternative solution?

@DylanDylann
Copy link
Contributor

@ntdiary

For @DylanDylann's proposal, isOffline does not work when editing waypoints offline.

I think it is correct because when editing waypoint offline we can't get new route and new distance, it is suitable to display default map and TBD in the amount field

Copy link

melvin-bot bot commented Dec 5, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@ntdiary
Copy link
Contributor

ntdiary commented Dec 7, 2023

@ntdiary What about my alternative solution?

@DylanDylann, I'm also not sure why we need to set pendingField.waypoint. However, isLoading is also consistent with optimistic behavior here.

@ntdiary

For @DylanDylann's proposal, isOffline does not work when editing waypoints offline.

I think it is correct because when editing waypoint offline we can't get new route and new distance, it is suitable to display default map and TBD in the amount field

I was saying that your solution cannot guarantee that users will see TBD only after clicking Save(in offline mode). :)

@paultsimura
Copy link
Contributor

there are still some details that need optimization

@ntdiary I assume this is the reason you didn't approve the proposal yet. Could you please point to them so we could move closer to the C+ approval?

@ntdiary
Copy link
Contributor

ntdiary commented Dec 8, 2023

there are still some details that need optimization

@ntdiary I assume this is the reason you didn't approve the proposal yet. Could you please point to them so we could move closer to the C+ approval?

Nope, I am also investigating pendingFields.waypoints. 😂

@melvin-bot melvin-bot bot added the Overdue label Dec 11, 2023
@ntdiary
Copy link
Contributor

ntdiary commented Dec 11, 2023

The code on the main branch has been changed. Ideally, this issue should have been fixed. However, it seems that the condition was reversed. I left a comment here #28618 (comment).

function saveWaypoint(transactionID: string, index: string, waypoint: RecentWaypoint | null, isDraft = false) {
Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION : ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {
pendingFields: {
waypoints: isDraft ? CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE : CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
},

Ah, sorry, the latest code has a lot of changes. The conclusion above may not be correct. I need to investigate it further. 😅

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 13, 2023
Copy link

melvin-bot bot commented Dec 13, 2023

📣 @ntdiary 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Dec 13, 2023

📣 @DylanDylann 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Dec 14, 2023
@DylanDylann
Copy link
Contributor

@ntdiary #33043
the PR is ready for review. Please help to re-assign to you

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Dec 21, 2023
@melvin-bot melvin-bot bot changed the title [$500] Distance - Map, amount and distance in the background shows TBD when editing distance [HOLD for payment 2023-12-28] [$500] Distance - Map, amount and distance in the background shows TBD when editing distance Dec 21, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 21, 2023
Copy link

melvin-bot bot commented Dec 21, 2023

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

Copy link

melvin-bot bot commented Dec 21, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.14-6 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 2023-12-28. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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

Copy link

melvin-bot bot commented Dec 21, 2023

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:

  • [@ntdiary] The PR that introduced the bug has been identified. Link to the PR:
  • [@ntdiary] 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:
  • [@ntdiary] 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:
  • [@ntdiary] Determine if we should create a regression test for this bug.
  • [@ntdiary] 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.
  • [@adelekennedy] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 Overdue and removed Weekly KSv2 labels Dec 27, 2023
Copy link

melvin-bot bot commented Jan 1, 2024

@ntdiary, @adelekennedy, @hayata-suenaga, @DylanDylann Eep! 4 days overdue now. Issues have feelings too...

1 similar comment
Copy link

melvin-bot bot commented Jan 1, 2024

@ntdiary, @adelekennedy, @hayata-suenaga, @DylanDylann Eep! 4 days overdue now. Issues have feelings too...

@DylanDylann
Copy link
Contributor

@adelekennedy Could you help to move forward with this issue?
cc @ntdiary

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jan 2, 2024
@ntdiary
Copy link
Contributor

ntdiary commented Jan 5, 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:

  • [@ntdiary] The PR that introduced the bug has been identified. Link to the PR: 26141
  • [@ntdiary] 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: https://github.com/Expensify/App/pull/26141/files#r1442973530
  • [@ntdiary] 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: No need
  • [@ntdiary] Determine if we should create a regression test for this bug. No need
  • [@ntdiary] 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. No need
  • [@adelekennedy] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

I personally feel like regression test might not be very necessary, most of us will use pendingFields correctly, and the error here is unlikely to be repeated. :)

cc @adelekennedy

@melvin-bot melvin-bot bot removed the Overdue label Jan 5, 2024
@adelekennedy
Copy link

Back from ooo and picking this up - I agree we can skip the regression test here!

Payouts due:

Contributor: $500 @ntdiary
Contributor+: $500 @DylanDylann

Upwork job is here.

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

8 participants