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

[$250] Expenses - Deleted Expense that was edited appears when user goes offline #49329

Open
2 of 6 tasks
IuliiaHerets opened this issue Sep 17, 2024 · 22 comments
Open
2 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Sep 17, 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: 9.0.36-1
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

  1. Submit any expense to Workspace or 1:1 chat
  2. Tap and edit any details of the expense
  3. Tap header of expense and delete expense
  4. After returning to chat, go offline

Expected Result:

Deleted expense doesn't appear

Actual Result:

Deleted expense re-appears greyed out and says "user owes" after going offline

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6606016_1726527694571.Screen_Recording_2024-09-16_at_5.54.04_PM.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021836153049228663209
  • Upwork Job ID: 1836153049228663209
  • Last Price Increase: 2024-09-24
  • Automatic offers:
    • huult | Contributor | 104163087
Issue OwnerCurrent Issue Owner: @aimane-chnaif
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 17, 2024
Copy link

melvin-bot bot commented Sep 17, 2024

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@IuliiaHerets
Copy link
Author

@mallenexpensify 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

@mallenexpensify mallenexpensify added the External Added to denote the issue can be worked on by a contributor label Sep 17, 2024
@melvin-bot melvin-bot bot changed the title Expenses - Deleted Expense that was edited appears when user goes offline [$250] Expenses - Deleted Expense that was edited appears when user goes offline Sep 17, 2024
Copy link

melvin-bot bot commented Sep 17, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 17, 2024
Copy link

melvin-bot bot commented Sep 17, 2024

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

@mallenexpensify
Copy link
Contributor

👀 plz @aimane-chnaif . Can you confirm that you're able to reproduce? It appears I was but I ran into a couple issues an my flow was funky.

2024-09-17_14-14-22.mp4

@aimane-chnaif
Copy link
Contributor

reproduced on latest staging v9.0.37-3

bug.mp4

@huult
Copy link
Contributor

huult commented Sep 22, 2024

Proposal

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

Deleted Expense that was edited appears when user goes offline

What is the root cause of that problem?

The reason for this issue is that reportAction.pendingAction is not updated when the DeleteMoneyRequest command is called. As a result, reportAction.pendingAction remains delete after the command is executed. This causes the condition ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID) to return true, and since isOffline is also true, the issue occurs

(reportAction) =>
(isOffline ||
ReportActionsUtils.isDeletedParentAction(reportAction) ||
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ||
reportAction.errors) &&
ReportActionsUtils.shouldReportActionBeVisible(reportAction, reportAction.reportActionID),

The reason DeleteMoneyRequest did not update pendingAction is because we called the UpdateMoneyRequestDate command to update the date, and it returned a lastUpdateID greater than DeleteMoneyRequest.

if (requestsToIgnoreLastUpdateID.includes(request.command) || !OnyxUpdates.doesClientNeedToBeUpdated(Number(response?.previousUpdateID ?? 0))) {

The warning I mentioned for that.

Screenshot 2024-09-22 at 15 10 53

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

We need the backend to update lastUpdateID for DeleteMoneyRequest because we send clientUpdateID to the API, but the response contains a different value, as shown in the image below:

send clientUpdateID: 1973749768

Screenshot 2024-09-22 at 15 51 39

and reponse previousUpdateID: 1973749978 that should be previousUpdateID: 1973749769 and lastUpdateID: 1973749980

Screenshot 2024-09-22 at 15 52 05

or
If we don't want to update the backend, then we should add the command DELETE_MONEY_REQUEST to the ignore list, something like this:

// ./src/libs/Middleware/SaveResponseInOnyx.ts#L8
const requestsToIgnoreLastUpdateID: string[] = [
    WRITE_COMMANDS.OPEN_APP,
+   WRITE_COMMANDS.DELETE_MONEY_REQUEST,
     ...
];
POC
Screen.Recording.2024-09-22.at.15.37.25.mp4

@melvin-bot melvin-bot bot added the Overdue label Sep 22, 2024
@mallenexpensify
Copy link
Contributor

@aimane-chnaif 👀 on @huult 's proposal above plz

@aimane-chnaif
Copy link
Contributor

@huult thanks for the proposal.

The reason for this issue is that reportAction.pendingAction is not updated when the DeleteMoneyRequest command is called.

This doesn't make sense to me. We're setting pendingAction to null upon DeleteMoneyRequest api success:

App/src/libs/actions/IOU.ts

Lines 5944 to 5953 in a99cf94

{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[reportPreviewAction?.reportActionID ?? '-1']: {
pendingAction: null,
errors: null,
},
},
},

@melvin-bot melvin-bot bot removed the Overdue label Sep 23, 2024
@aimane-chnaif
Copy link
Contributor

I noticed that this bug only happens when edit date field. Not happening on other fields like description.
So I don't think the bug is related to lastUpdateID for DeleteMoneyRequest.

@huult
Copy link
Contributor

huult commented Sep 24, 2024

The reason DeleteMoneyRequest did not update pendingAction is because we called the UpdateMoneyRequestDate command to update the date, and it returned a lastUpdateID greater than DeleteMoneyRequest.

Can you check this command? The API responds, but the data is not stored locally due to the reason I mentioned. You can add a log above this condition, and you will see.

@aimane-chnaif
Copy link
Contributor

@huult please also check #49329 (comment).
Please explain why this happens only on date field.

@aimane-chnaif
Copy link
Contributor

The root cause is quite similar to #44114 (comment)
Possibly fix in BE 🎀👀🎀

Copy link

melvin-bot bot commented Sep 24, 2024

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

Copy link

melvin-bot bot commented Sep 24, 2024

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

@mallenexpensify
Copy link
Contributor

@jasperhuangg , can you confirm if you think this issue is BE?
You don't need to leave yourself assigned.

@jasperhuangg

This comment was marked as outdated.

@melvin-bot melvin-bot bot added the Overdue label Sep 26, 2024
@huult
Copy link
Contributor

huult commented Sep 27, 2024

@jasperhuangg , When does the expense delete successfully on the server? I waited for 1 minute and disconnected the network, but the issue still occurred.
If we know when the deletion is successful, I suggest keeping the data, including the amount, until it is deleted on the server and then deleting it.

@jasperhuangg
Copy link
Contributor

@huult, I see; sorry for the misunderstanding. In that case, your alternative approach of adding the command to the ignore list should work! If the user intends to delete the money request, it doesn't seem like we need to wait for any requests to update fields in the money request.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 27, 2024
Copy link

melvin-bot bot commented Sep 27, 2024

📣 @huult 🎉 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 removed the Overdue label Sep 27, 2024
Copy link

melvin-bot bot commented Sep 27, 2024

@mallenexpensify, @jasperhuangg, @aimane-chnaif Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Sep 28, 2024
@huult
Copy link
Contributor

huult commented Sep 28, 2024

The PR for this issue is already open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
Status: No status
Development

No branches or pull requests

5 participants