App icon indicating copy to clipboard operation
App copied to clipboard

[$250] Search - Expense from the list does not disappear after deletion

Open IuliiaHerets opened this issue 1 year ago β€’ 10 comments

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:

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

Screenshots/Videos

https://github.com/user-attachments/assets/917c7a77-9d7d-4aaf-8cfa-25d030038739

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-06
Issue OwnerCurrent Issue Owner: @rayane-djouah

IuliiaHerets avatar Dec 06 '24 09:12 IuliiaHerets

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.

melvin-bot[bot] avatar Dec 06 '24 09:12 melvin-bot[bot]

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:

https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/hooks/useSearchHighlightAndScroll.ts#L42

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:

https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/hooks/useSearchHighlightAndScroll.ts#L42

        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)

daledah avatar Dec 06 '24 13:12 daledah

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 https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/hooks/useSearchHighlightAndScroll.ts#L42 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 https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/hooks/useSearchHighlightAndScroll.ts#L42 https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/hooks/useSearchHighlightAndScroll.ts#L37 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) https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/hooks/useSearchHighlightAndScroll.ts#L76-L80

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

and replace this with it https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/hooks/useSearchHighlightAndScroll.ts#L42

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 https://github.com/Expensify/App/blob/b9107bf59cbb3982d958abbae357e3b903ed4c63/src/hooks/useSearchHighlightAndScroll.ts#L37

        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)

FitseTLT avatar Dec 06 '24 14:12 FitseTLT

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

melvin-bot[bot] avatar Dec 06 '24 23:12 melvin-bot[bot]

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

melvin-bot[bot] avatar Dec 06 '24 23:12 melvin-bot[bot]

@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 :/

mallenexpensify avatar Dec 06 '24 23:12 mallenexpensify

Reproducible

https://github.com/user-attachments/assets/55d39fad-ec3d-45bc-88c5-8aa6eaf8abef

rayane-d avatar Dec 10 '24 00:12 rayane-d

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-d avatar Dec 10 '24 00:12 rayane-d

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

rayane-d avatar Dec 10 '24 00:12 rayane-d

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.

FitseTLT avatar Dec 10 '24 13:12 FitseTLT

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

melvin-bot[bot] avatar Dec 13 '24 16:12 melvin-bot[bot]

Will review today

rayane-d avatar Dec 13 '24 16:12 rayane-d

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

melvin-bot[bot] avatar Dec 17 '24 09:12 melvin-bot[bot]

@luacmartins - Some thoughts:

  • https://github.com/Expensify/App/pull/49192 added the logic to trigger the search command and highlight the newly added expense when adding a new expense from the search page, as requested in, as requested in https://github.com/Expensify/App/issues/48716
  • Triggering the search command when deleting expenses from the search page wasn't considered in the initial design.
  • @daledah's proposal correctly identifies the cause and addresses the deletion issue (by checking if the number of transactions has decreased), but it doesn't handle cases where a transaction is replaced in Onyx (since the transaction count remains the same).
  • @FitseTLT proposal covers the case where a transaction is replaced in Onyx by performing a deep comparison of the previous and current transaction IDs.
  • @FitseTLT also suggested adding unit tests.
  • Since useSearchHighlightAndScroll initially focused only on highlighting and scrolling for newly added transactions, we may need to rename it or add comments to clarify that it now also handles transaction deletions.

I think we can go with @FitseTLT proposal

:ribbon::eyes::ribbon: C+ reviewed

rayane-d avatar Dec 17 '24 11:12 rayane-d

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

melvin-bot[bot] avatar Dec 17 '24 11:12 melvin-bot[bot]

I agree. Thanks for the detailed summary!

luacmartins avatar Dec 17 '24 16:12 luacmartins

πŸ“£ @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

melvin-bot[bot] avatar Dec 17 '24 16:12 melvin-bot[bot]

πŸ“£ @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 πŸ“–

melvin-bot[bot] avatar Dec 17 '24 16:12 melvin-bot[bot]

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

melvin-bot[bot] avatar Dec 20 '24 09:12 melvin-bot[bot]

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?

luacmartins avatar Jan 10 '25 19:01 luacmartins

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

FitseTLT avatar Jan 10 '25 20:01 FitseTLT

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

luacmartins avatar Jan 10 '25 20:01 luacmartins

@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 :+1:

FitseTLT avatar Jan 10 '25 20:01 FitseTLT

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

https://github.com/user-attachments/assets/19d19cd5-4656-44a9-ad99-5896b7b094d2

luacmartins avatar Jan 10 '25 20:01 luacmartins

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

https://github.com/user-attachments/assets/ccaf49c5-4adc-4927-8877-f7cc5d283c82

https://github.com/user-attachments/assets/c45fde0e-6ad6-48fa-9bac-b91c301a260d

FitseTLT avatar Jan 10 '25 21:01 FitseTLT

No BE changes that I'm aware of.

luacmartins avatar Jan 10 '25 21:01 luacmartins

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 πŸ‘

FitseTLT avatar Jan 10 '25 22:01 FitseTLT

This issue has not been updated in over 15 days. @luacmartins, @mallenexpensify, @FitseTLT, @rayane-djouah eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

melvin-bot[bot] avatar Jan 13 '25 09:01 melvin-bot[bot]

PR under review

rayane-d avatar Jan 13 '25 10:01 rayane-d

PR is merged

rayane-d avatar Jan 23 '25 19:01 rayane-d