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] [Search v1.2] Expense preview count & expense report do not update after deleting expense from Search #47617

Closed
6 tasks done
IuliiaHerets opened this issue Aug 18, 2024 · 40 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Aug 18, 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: v9.0.21-3
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. Go to staging.new.expensify.com
  2. Go to FAB > Submit expense > Manual.
  3. Submit two expenses to any user.
  4. Go to Search.
  5. Select one of the submitted expenses in Step 3 via checkbox.
  6. Click on the dropdown > Delete.
  7. Delete the expense.
  8. Go back to Inbox.
  9. Open DM with the user in Step 3.
  10. Click on the expense preview.

Expected Result:

In Step 9, the expense preview count should update and no longer shows "2 expenses".
In Step 10, the expense report will be a combined report as there is only one expense.

Actual Result:

In Step 9, the expense preview count does not update and still shows "2 expenses".
In Step 10, the expense report does not show combined report when there is only one expense.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6575243_1723987158308.20240818_211250.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0164693244e7052703
  • Upwork Job ID: 1825574897454530648
  • Last Price Increase: 2024-08-19
Issue OwnerCurrent Issue Owner: @luacmartins
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Aug 18, 2024
Copy link

melvin-bot bot commented Aug 18, 2024

Triggered auto assignment to @sakluger (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

We think that this bug might be related to #wave-collect - Release 1

@IuliiaHerets
Copy link
Author

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

@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Aug 19, 2024
@melvin-bot melvin-bot bot changed the title Search-Expense preview count & expense report do not update after deleting expense from Search [$250] Search-Expense preview count & expense report do not update after deleting expense from Search Aug 19, 2024
Copy link

melvin-bot bot commented Aug 19, 2024

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

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

melvin-bot bot commented Aug 19, 2024

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

@MarynaKip
Copy link

MarynaKip commented Aug 19, 2024

Proposal

Need to have an updated transactions list while creating supportText in ReportPreview.tsx. For this the deleted transactions should be set to null.

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

The transactions list consists deleted transactions.

What is the root cause of that problem?

During the deletion process - transactions are not deleting, and still exists in the transactions list. That's why the number of shown transactions is wrong.

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

Set deleted transactions to null

What alternative solutions did you explore? (Optional)

N/A

Copy link

melvin-bot bot commented Aug 19, 2024

📣 @MarynaKip! 📣
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>

@MarynaKip
Copy link

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~0135072b780205cb5e

Copy link

melvin-bot bot commented Aug 19, 2024

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@Amoralchik
Copy link
Contributor

Amoralchik commented Aug 19, 2024

@MarynaKip
Please make sure you've read Contributing to Expensify and once you've understood everything, please format your comment according to the proposal template if you're interested in fixing this issue; otherwise, it won't be considered for review.

@Amoralchik
Copy link
Contributor

Amoralchik commented Aug 19, 2024

Edited by proposal-police: This proposal was edited at 2023-10-07T14:30:00Z.

Proposal

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

expense report do not update after deleting expense from Search

What is the root cause of that problem?

After deleting a transaction on the Search page, the transaction still remains in ONYX.

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

We can change the deleteMoneyRequestOnSearch logic to match what we use in deleteMoneyRequest.
This will protect us from issues like the ones described by codewaseem.

For convenience, the entire code is included here:
https://gist.github.com/Amoralchik/2fe619f19faa22aabd289e8a23fb2687#file-search-ts-L100

Thus, after executing the API request, we will remove the transaction data from Onyx.

What alternative solutions did you explore? (Optional)

I’m leaving the previous suggestion in the alternative solutions section.

transactionIDList.forEach((transactionID) => {
    optimisticData.push({
        onyxMethod: Onyx.METHOD.SET,
        key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
        value: {},
    });
    finallyData.push({
        onyxMethod: Onyx.METHOD.SET,
        key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
        value: {},
    });
});

@codewaseem
Copy link
Contributor

Proposal

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

The expense preview count does not get updated when the report is deleted from the Search page.

What is the root cause of that problem?

The corresponding transactions are not set to null and the report actions are not filtered out if deleted.

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

Only setting the transactions to null will fix the count as also suggested by @Amoralchik, but it causes this bug.
Screenshot 2024-08-20 at 04 23 48

We also need to filter out the deleted report action from ReportScreen using ReportActionsUtils.isDeletedAction(reportAction)

What alternative solutions did you explore? (Optional)

Alternatively, we can follow a similar approach as done in deleteMoneyRequest to handle other scenarious if needed.

App/src/libs/actions/IOU.ts

Lines 5754 to 5984 in 78c20f0

function deleteMoneyRequest(transactionID: string, reportAction: OnyxTypes.ReportAction, isSingleTransactionView = false) {
// STEP 1: Calculate and prepare the data
const {
shouldDeleteTransactionThread,
shouldDeleteIOUReport,
updatedReportAction,
updatedIOUReport,
updatedReportPreviewAction,
transactionThreadID,
transactionThread,
chatReport,
transaction,
transactionViolations,
iouReport,
reportPreviewAction,
urlToNavigateBack,
} = prepareToCleanUpMoneyRequest(transactionID, reportAction, isSingleTransactionView);
// STEP 2: Build Onyx data
// The logic mostly resembles the cleanUpMoneyRequest function
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: null,
},
];
optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
value: null,
});
if (shouldDeleteTransactionThread) {
optimisticData.push(
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: null,
},
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transactionThreadID}`,
value: null,
},
);
}
optimisticData.push(
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
value: updatedReportAction,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`,
value: updatedIOUReport,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[reportPreviewAction?.reportActionID ?? '-1']: updatedReportPreviewAction,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`,
value: ReportUtils.getOutstandingChildRequest(updatedIOUReport),
},
);
if (!shouldDeleteIOUReport && updatedReportPreviewAction?.childMoneyRequestCount === 0) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`,
value: {
hasOutstandingChildRequest: false,
},
});
}
if (shouldDeleteIOUReport) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`,
value: {
hasOutstandingChildRequest: false,
iouReportID: null,
lastMessageText: ReportActionsUtils.getLastVisibleMessage(iouReport?.chatReportID ?? '-1', {[reportPreviewAction?.reportActionID ?? '-1']: null})?.lastMessageText,
lastVisibleActionCreated: ReportActionsUtils.getLastVisibleAction(iouReport?.chatReportID ?? '-1', {[reportPreviewAction?.reportActionID ?? '-1']: null})?.created,
},
});
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`,
value: {
pendingFields: {
preview: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
},
},
});
}
const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
value: {
[reportAction.reportActionID]: shouldDeleteIOUReport
? null
: {
pendingAction: null,
},
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[reportPreviewAction?.reportActionID ?? '-1']: {
pendingAction: null,
errors: null,
},
},
},
];
if (shouldDeleteIOUReport) {
successData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`,
value: null,
});
}
const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: transaction ?? null,
},
];
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
value: transactionViolations ?? null,
});
if (shouldDeleteTransactionThread) {
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadID}`,
value: transactionThread,
});
}
const errorKey = DateUtils.getMicroseconds();
failureData.push(
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReport?.reportID}`,
value: {
[reportAction.reportActionID]: {
...reportAction,
pendingAction: null,
errors: {
[errorKey]: Localize.translateLocal('iou.error.genericDeleteFailureMessage'),
},
},
},
},
shouldDeleteIOUReport
? {
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`,
value: iouReport,
}
: {
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`,
value: iouReport,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`,
value: {
[reportPreviewAction?.reportActionID ?? '-1']: {
...reportPreviewAction,
pendingAction: null,
errors: {
[errorKey]: Localize.translateLocal('iou.error.genericDeleteFailureMessage'),
},
},
},
},
);
if (chatReport && shouldDeleteIOUReport) {
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport.reportID}`,
value: chatReport,
});
}
if (!shouldDeleteIOUReport && updatedReportPreviewAction?.childMoneyRequestCount === 0) {
failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`,
value: {
hasOutstandingChildRequest: true,
},
});
}
const parameters: DeleteMoneyRequestParams = {
transactionID,
reportActionID: reportAction.reportActionID,
};
// STEP 3: Make the API request
API.write(WRITE_COMMANDS.DELETE_MONEY_REQUEST, parameters, {optimisticData, successData, failureData});
CachedPDFPaths.clearByKey(transactionID);
return urlToNavigateBack;
}

@paultsimura
Copy link
Contributor

@ikevin127 another weird timecode by the proposal-police: #47617 (comment)

Is it being worked on?

@ikevin127
Copy link
Contributor

@paultsimura We just pushed some changes related to this last week but seems like this is still happening. Digging into it to find out why ⛏️

@paultsimura
Copy link
Contributor

paultsimura commented Aug 21, 2024

Tagging @luacmartins since I believe you've worked with the bulk actions on the BE side.

This might be a BE issue: the DeleteMoneyRequestOnSearch call does not return the transaction removal Onyx operation:

image

Could you please verify?
This also leads to expenses re-appearing on the search list after bulk removal. But clicking on them leads to "Not found" page.

@luacmartins
Copy link
Contributor

Yea, I agree this is a BE issue and we're missing sending those updates.

@luacmartins luacmartins added Internal Requires API changes or must be handled by Expensify staff Hot Pick Ready for an engineer to pick up and run with and removed External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors labels Aug 22, 2024
@trjExpensify
Copy link
Contributor

Moving to wave-control project.

@melvin-bot melvin-bot bot added the Overdue label Aug 26, 2024
@luacmartins
Copy link
Contributor

luacmartins commented Aug 26, 2024

This seems to have the same root cause as #47385.

@sakluger
Copy link
Contributor

I asked again for a retest in the Slack QA channel: https://expensify.slack.com/archives/C9YU7BX5M/p1726853413386789

@sakluger sakluger changed the title [$250] [Search v1.2] Expense preview count & expense report do not update after deleting expense from Search [HOLD for retest] [$250] [Search v1.2] Expense preview count & expense report do not update after deleting expense from Search Sep 20, 2024
@sakluger sakluger removed the Hot Pick Ready for an engineer to pick up and run with label Sep 20, 2024
@m-natarajan
Copy link

Able to reproduce this

20240921_183532.mp4

@sakluger
Copy link
Contributor

@luacmartins it seems that the hold issue didn't fix this one. Any ideas why it didn't fix this one?

@luacmartins
Copy link
Contributor

Not sure, gonna remove the hold to investigate.

@luacmartins luacmartins changed the title [HOLD for retest] [$250] [Search v1.2] Expense preview count & expense report do not update after deleting expense from Search [$250] [Search v1.2] Expense preview count & expense report do not update after deleting expense from Search Sep 26, 2024
@luacmartins luacmartins added Daily KSv2 and removed Weekly KSv2 retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause labels Sep 26, 2024
@luacmartins luacmartins self-assigned this Sep 26, 2024
@melvin-bot melvin-bot bot added the Overdue label Sep 30, 2024
Copy link

melvin-bot bot commented Sep 30, 2024

@sakluger, @paultsimura, @luacmartins Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@paultsimura
Copy link
Contributor

Not overdue, waiting for @luacmartins.

@luacmartins
Copy link
Contributor

Haven't been able to prioritize this one yet, but it's on my list for this week.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 1, 2024
@sakluger
Copy link
Contributor

sakluger commented Oct 7, 2024

@luacmartins any updates?

Copy link

melvin-bot bot commented Oct 7, 2024

@sakluger, @paultsimura, @luacmartins Huh... This is 4 days overdue. Who can take care of this?

@luacmartins
Copy link
Contributor

I'm working on a draft PR

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 9, 2024
@luacmartins
Copy link
Contributor

PR in review

@melvin-bot melvin-bot bot removed the Overdue label Oct 11, 2024
@luacmartins luacmartins added Reviewing Has a PR in review Overdue labels Oct 11, 2024
@melvin-bot melvin-bot bot removed the Overdue label Oct 11, 2024
@sakluger
Copy link
Contributor

@luacmartins I see that the PR was deployed. Does anything else need to be done here? Otherwise, I think we can just close the issue since there was no C+ review.

@luacmartins
Copy link
Contributor

luacmartins commented Oct 17, 2024

I think we're good to close. Thanks for the ping!

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. Daily KSv2 Internal Requires API changes or must be handled by Expensify staff Reviewing Has a PR in review
Projects
Status: Done
Development

No branches or pull requests

10 participants