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

[$500] Web - Report Preview in Report Screen shows up even after deletion of Money Request #26627

Closed
1 of 6 tasks
kbecciv opened this issue Sep 3, 2023 · 30 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Internal Requires API changes or must be handled by Expensify staff Weekly KSv2

Comments

@kbecciv
Copy link

kbecciv commented Sep 3, 2023

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


Action Performed:

  1. Use FAB on a ChatReport and generate money request
  2. Click on IOUReport to show the IOUReport
  3. Use menu to delete the Money Request
  4. Come back to ChatReport of Step 1
  5. Reload the page.

Expected Result:

Report Previous should not show up for a deleted Money Request

Actual Result:

Report Preview shows up for a deleted Money Request

Workaround:

Unknown

Platforms:

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

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.62.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
Notes/Photos/Videos: Any additional supporting documentation

deletemrfails.mp4
Recording.4231.mp4

Expensify/Expensify Issue URL:
Issue reported by: @rojiphil
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693399731169779

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013c7ff8faa3f9e5a6
  • Upwork Job ID: 1704099592925270016
  • Last Price Increase: 2023-09-26
@kbecciv kbecciv added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 3, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 3, 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

@rojiphil
Copy link
Contributor

rojiphil commented Sep 4, 2023

Proposal

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

Web - Report Preview in Report Screen shows up even after deletion of Money Request

What is the root cause of that problem?

The problem occurs because we are not clearing the Report Preview on the deletion of the IOU Report. . Further, pendingAction is not set for ReportPreview for Offline support.

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

  1. This can be solved by clearing up the Report Preview when IOU Report is deleted at this location within successData of deleteMoneyRequest method

The changes can be as follows:

        ...(shouldDeleteIOUReport
            ? [
                {
                    onyxMethod: Onyx.METHOD.MERGE,
                    key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`,
                    value: {
                        [reportPreviewAction.reportActionID]: {
                            pendingAction: null,
                            message: [
                                {
                                    type: 'COMMENT',
                                    html: '',
                                    text: '',
                                    isEdited: true,
                                },
                            ],
                            errors: null,
                        },
                    },
                },
              ]
            : []),        
  1. In addition, we need to support offline mode. For this, we can add the pendingAction to DELETE as follows here
    let updatedReportPreviewAction = {...reportPreviewAction};
    if(shouldDeleteIOUReport)
    {
        updatedReportPreviewAction.pendingAction = CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
        updatedReportPreviewAction.errors = null;
    }

What alternative solutions did you explore? (Optional)

@s-alves10
Copy link
Contributor

s-alves10 commented Sep 4, 2023

Proposal

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

Report preview in report page shows again even after money request is deleted

What is the root cause of that problem?

When we delete a money request, deleteMoneyRequest function is called.
As you can see, if shouldDeleteIOUReport is true, we optimistically merge the report preview action with null

App/src/libs/actions/IOU.js

Lines 1183 to 1189 in d971190

{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport.reportID}`,
value: {
[reportPreviewAction.reportActionID]: updatedReportPreviewAction,
},
},

And the deleteMoneyRequest API returns {[reportPreviewActionID]: null}, too.
The problem is in Onyx.merge

Please check the code here

We remove the keys with null value in modifiedData and call Storage.mergeItem. This means null values are not updated in storage though they are updated in memory. This bug looks like was introduced by this PR

This is the root cause of this issue

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

In Onyx.merge function, we merge the changes with existing data and remove all keys with null values, we have to call Storage.setItem instead of Storage.mergeItem

This works as expected

Result
26627.mp4

What alternative solutions did you explore? (Optional)

@chrispader
Copy link
Contributor

Calling Storage.setItem instead of Storage.mergeItem is definitely not what we want to do here, because we added JSON_PATCH functionality for SQLite on native here.

I just discovered the potential problem. I think it’s related to the idb-keyval PR by @hannojg. The problem is, that before this PR, on web we just set the modified data with the nullish keys removed already. After this PR, on web we’re using yet another merge funcationality, which will not drop the nullish keys, because the modified data with the removed nullish keys will be merged.

I’m gonna open a PR, which fixes this.

@s-alves10
Copy link
Contributor

I hope you open the PR asap. I think this bug may cause several issues

@melvin-bot
Copy link

melvin-bot bot commented Sep 11, 2023

@muttmuure Still overdue 6 days?! Let's take care of this!

@chrispader
Copy link
Contributor

I hope you open the PR asap. I think this bug may cause several issues

@s-alves10 just created a PR in Onyx that fixes this issue: Expensify/react-native-onyx#333

@melvin-bot
Copy link

melvin-bot bot commented Sep 13, 2023

@muttmuure 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

@melvin-bot
Copy link

melvin-bot bot commented Sep 15, 2023

@muttmuure 10 days overdue. I'm getting more depressed than Marvin.

@melvin-bot
Copy link

melvin-bot bot commented Sep 17, 2023

@muttmuure this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@muttmuure muttmuure added the External Added to denote the issue can be worked on by a contributor label Sep 19, 2023
@melvin-bot melvin-bot bot changed the title Web - Report Preview in Report Screen shows up even after deletion of Money Request [$500] Web - Report Preview in Report Screen shows up even after deletion of Money Request Sep 19, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

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

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

melvin-bot bot commented Sep 19, 2023

Current assignee @muttmuure is eligible for the External assigner, not assigning anyone new.

@muttmuure
Copy link
Contributor

I was out last week. Catching up this week

@melvin-bot
Copy link

melvin-bot bot commented Sep 19, 2023

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

@melvin-bot melvin-bot bot added the Overdue label Sep 22, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 24, 2023

@allroundexperts @muttmuure this issue is now 3 weeks old. There is one more week left before this issue breaks WAQ and will need to go internal. What needs to happen to get a PR in review this week? Please create a thread in #expensify-open-source to discuss. Thanks!

@melvin-bot
Copy link

melvin-bot bot commented Sep 25, 2023

@allroundexperts, @muttmuure Huh... This is 4 days overdue. Who can take care of this?

@muttmuure
Copy link
Contributor

@allroundexperts can you verify if @chrispader's PR fixes this?

@melvin-bot melvin-bot bot removed the Overdue label Sep 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Sep 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Sep 29, 2023

@allroundexperts, @muttmuure Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot
Copy link

melvin-bot bot commented Oct 1, 2023

@allroundexperts @muttmuure this issue is now 4 weeks old and preventing us from maintaining WAQ, can you:

  • Decide whether any proposals currently meet our guidelines and can be approved as-is today
  • If no proposals meet that standard, please take this issue internal and treat it as one of your highest priorities
  • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

Thanks!

@melvin-bot melvin-bot bot added Internal Requires API changes or must be handled by Expensify staff 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 Oct 1, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 1, 2023

Current assignee @allroundexperts is eligible for the Internal assigner, not assigning anyone new.

@melvin-bot
Copy link

melvin-bot bot commented Oct 3, 2023

@allroundexperts, @muttmuure 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

@muttmuure
Copy link
Contributor

No proposals, going to come back in a week and see if this is reproducible

@melvin-bot melvin-bot bot removed the Overdue label Oct 3, 2023
@muttmuure muttmuure added Weekly KSv2 and removed Daily KSv2 labels Oct 3, 2023
@rojiphil
Copy link
Contributor

rojiphil commented Oct 3, 2023

@muttmuure
As I understand, the PR in this comment was supposed to resolve this issue.
@chrispader @s-alves10 can confirm

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

@mvtglobally
Copy link

Issue not reproducible during KI retests. (Second week)

@melvin-bot melvin-bot bot added the Overdue label Oct 12, 2023
@rojiphil
Copy link
Contributor

@allroundexperts @muttmuure
Can we not close this issue if the issue is fixed already?
Also, there are other issues dependent on the resolution of this one. Closing this would help us move further on the other issues.

@miljakljajic
Copy link
Contributor

This hasn't been reproducible for two weeks [following this PR] (#26627 (comment)) - closing. Thank you @rojiphil !

@rojiphil
Copy link
Contributor

@miljakljajic @muttmuure
Don't I qualify for a reporter bonus here as I had reported the bug?

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. Engineering Internal Requires API changes or must be handled by Expensify staff Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants