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 - Expense from the list does not disappear after deletion #53687

Open
8 tasks done
IuliiaHerets opened this issue Dec 6, 2024 · 27 comments
Open
8 tasks done
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 Dec 6, 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.72-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5309274
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team

Action Performed:

  1. Open HybridApp
  2. Log in to the HT account
  3. Send 2 manual expenses to any user
  4. Go to Search -> Expenses -> All
  5. Delete one of the created expenses from step 3
  6. Tap again on the deleted expense

Expected Result:

After deleting an expense, it should immediately disappear from the list without refreshing the page

Actual Result:

Expense from the list does not disappear after deletion

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6685819_1733443178341.ScreenRecording_12-06-2024_04-50-37_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021865183017070238528
  • Upwork Job ID: 1865183017070238528
  • Last Price Increase: 2024-12-13
  • Automatic offers:
    • rayane-djouah | Reviewer | 105373332
    • FitseTLT | Contributor | 105373334
Issue OwnerCurrent Issue Owner: @rayane-djouah
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 6, 2024
Copy link

melvin-bot bot commented Dec 6, 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.

@daledah
Copy link
Contributor

daledah commented Dec 6, 2024

Proposal

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

Expense from the list does not disappear after deletion

What is the root cause of that problem?

In useSearchHighlightAndScroll, we only update Search data if new transaction is added, not when a transaction is deleted:

if (transactionsLength && typeof previousTransactionsLength === 'number' && transactionsLength > previousTransactionsLength) {

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

Change condition to update Search data if number of transaction is different:

if (transactionsLength && typeof previousTransactionsLength === 'number' && transactionsLength > previousTransactionsLength) {

        if (transactionsLength && typeof previousTransactionsLength === 'number' && transactionsLength !== previousTransactionsLength) {

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

What alternative solutions did you explore? (Optional)

@FitseTLT
Copy link
Contributor

FitseTLT commented Dec 6, 2024

Edited by proposal-police: This proposal was edited at 2024-12-06 15:01:26 UTC.

Proposal

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

Search - Expense from the list does not disappear after deletion

What is the root cause of that problem?

We only send search request if there is an increase in transaction length, i.e. the currentTransaction length is greater than the previous transaction length

if (transactionsLength && typeof previousTransactionsLength === 'number' && transactionsLength > previousTransactionsLength) {

but here we are deleting the expense that will decrease the transactions length we have

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

The conditions that depend on transaction length are incorrect in both

if (transactionsLength && typeof previousTransactionsLength === 'number' && transactionsLength > previousTransactionsLength) {

if (searchTriggeredRef.current || previousTransactionsLength === transactionsLength) {

because transaction length equality can even mean there is a change that needs a search request to be sent. For instance, if a user creates a new expense but deletes another expense which could result in the transaction lengths to be equal but still there is a change that requires a fetch.
We should instead depend on a condition where the previous and current transaction IDs list are not equal (of course with deep comparison between the values they hold)
const previousTransactionIDs = extractTransactionIDsFromSearchResults(previousSearchResults);
const currentTransactionIDs = extractTransactionIDsFromSearchResults(searchResults.data);
// Find new transaction IDs that are not in the previousTransactionIDs and not already highlighted
const newTransactionIDs = currentTransactionIDs.filter((id) => !previousTransactionIDs.includes(id) && !highlightedTransactionIDs.current.has(id));

const previousTransactionIDs = previousTransactions && Object.keys(previousTransactions);
        const transactionIDs = transactions && Object.keys(transactions);

and replace this with it

if (transactionsLength && typeof previousTransactionsLength === 'number' && transactionsLength > previousTransactionsLength) {

if(!isEqual(transactionIDs, previousTransactionIDs))

we can optionally add more condition of the existence of previous transaction ids and current transactionIDs to exclude the case where the values are undefined on first render 👍
and remove the condition here

if (searchTriggeredRef.current || previousTransactionsLength === transactionsLength) {

        if (searchTriggeredRef.current) {

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

We can render the Search page (or optionally test only useSearchHighlightAndScroll) and change the transaction list from onyx by replacing a transaction with another one and mock our SearchActions.search and assert that it has been called 👍

What alternative solutions did you explore? (Optional)

@mallenexpensify mallenexpensify added the External Added to denote the issue can be worked on by a contributor label Dec 6, 2024
@melvin-bot melvin-bot bot changed the title Search - Expense from the list does not disappear after deletion [$250] Search - Expense from the list does not disappear after deletion Dec 6, 2024
Copy link

melvin-bot bot commented Dec 6, 2024

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

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

melvin-bot bot commented Dec 6, 2024

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

@mallenexpensify
Copy link
Contributor

@rayane-djouah can you attempt reproduction and, if you're able to, review the above proposals? I tried to test and staging.new.expensify.com froze for me :/

@rayane-djouah
Copy link
Contributor

Reproducible

Screen.Recording.2024-12-10.at.1.52.09.AM.mov

@rayane-djouah
Copy link
Contributor

For instance, if a user creates a new expense but deletes another expense which could result in the transaction lengths to be equal but still there is a change that requires a fetch.

@FitseTLT Is the user currently able to create a new expense and delete another one at the same time?

@rayane-djouah
Copy link
Contributor

rayane-djouah commented Dec 10, 2024

@luacmartins would you like to be assigned to this one as CME since it's related to the search project?

@FitseTLT
Copy link
Contributor

For instance, if a user creates a new expense but deletes another expense which could result in the transaction lengths to be equal but still there is a change that requires a fetch.

@FitseTLT Is the user currently able to create a new expense and delete another one at the same time?

@rayane-djouah We are not only tracking the creation/deletion of transactions created by the current user, for instance, another user member of the current user's workspace can create an expense and delete another one and when the update of transaction reaches the current user's onyx the transaction length will be equal that's what I am indicating.

Copy link

melvin-bot bot commented Dec 13, 2024

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

@rayane-djouah
Copy link
Contributor

Will review today

@melvin-bot melvin-bot bot removed the Overdue label Dec 13, 2024
Copy link

melvin-bot bot commented Dec 17, 2024

@luacmartins, @mallenexpensify, @rayane-djouah Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Dec 17, 2024
@rayane-djouah
Copy link
Contributor

@luacmartins - Some thoughts:

I think we can go with @FitseTLT proposal

🎀👀🎀 C+ reviewed

@melvin-bot melvin-bot bot removed the Overdue label Dec 17, 2024
Copy link

melvin-bot bot commented Dec 17, 2024

Current assignee @luacmartins is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@luacmartins
Copy link
Contributor

I agree. Thanks for the detailed summary!

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

melvin-bot bot commented Dec 17, 2024

📣 @rayane-djouah 🎉 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 17, 2024

📣 @FitseTLT 🎉 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 📖

Copy link

melvin-bot bot commented Dec 20, 2024

@luacmartins @mallenexpensify @FitseTLT @rayane-djouah this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@luacmartins
Copy link
Contributor

Ok, I have PRs to update the responses from DeleteMoneyRequest and DeleteMoneyRequestOnSearch. Below is the sample response:

When deleting the last transaction on a report (no snapshot key is sent, since live updates should automatically update the snapshot)
Screenshot 2025-01-10 at 12 56 08 PM

When deleting a single transaction on a report with multiple expenses (snapshot key is returned to update isOneTransactionReport, etc)

Screenshot 2025-01-10 at 12 55 47 PM

@rayane-djouah @FitseTLT Does that update look correct to you?

@FitseTLT
Copy link
Contributor

@luacmartins I am a bit confused here. Currently useSearchHighlightAndScroll hook checks for a change in transactions_ key and send search request accordingly. Now the problem we are facing is transactions_ key is not being correctly updated on deleting the last transaction in a report I was hoping to get that transactions_ key update fixed on this case so that the normal operation of the hook will work for this case too.
I am not sure how the BE code works but I don't think fixing the response of DeleteRequest API only suffice but also the data it pushes too for other users that didn't delete the money request. Like User A deleted a request in workspace that is owned by UserB and now the update doesn't reach for both users.

@luacmartins
Copy link
Contributor

@FitseTLT yes, the data is being pushed to other users, but for some reason we're not returning it in the http response to the caller. So my PRs are adding all the onyxData updates to the http response. Does that make sense?

@FitseTLT
Copy link
Contributor

@FitseTLT yes, the data is being pushed to other users, but for some reason we're not returning it in the http response to the caller. So my PRs are adding all the onyxData updates to the http response. Does that make sense?

Yep. But if you want to test you can do with branch of the PR because the BE change should solve it without any more FE change 👍

@luacmartins
Copy link
Contributor

@FitseTLT doesn't seem to work. Check out the video below:

Screen.Recording.2025-01-10.at.1.44.26.PM.mov

@FitseTLT
Copy link
Contributor

@luacmartins Did you apply any BE changes? Because now it is working I remember invoice deletion was not updated too but it is working now.

2025-01-11.00-10-20.mp4
2025-01-11.00-07-46.mp4

@luacmartins
Copy link
Contributor

No BE changes that I'm aware of.

@FitseTLT
Copy link
Contributor

No BE changes that I'm aware of.

Ok but now the BE is correctly updating transactions_ list so it seems fixed. I will work on the rest of the tasks left but let u know if any BE change is needed. Maybe some other BE PR might have fixed it Thx 👍

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: Bugs and Follow Up Issues
Development

No branches or pull requests

6 participants