Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.56k stars 2.9k forks source link

[Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses #52369

Open IuliiaHerets opened 1 week ago

IuliiaHerets commented 1 week ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.60-0 Reproducible in staging?: Y Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: 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 Expensify/Expensify Issue URL: Issue reported by: Slack conversation (hyperlinked to channel name):

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Submit two expenses.
  4. Pay the expenses.
  5. Go to Search > All.

Expected Result:

Describe what you think should've happened

Actual Result:

Describe what actually happened

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

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

Screenshots/Videos

https://github.com/user-attachments/assets/2b6c006b-a2dd-449e-b60a-0986cd7bcb88

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021856301612409763010
  • Upwork Job ID: 1856301612409763010
  • Last Price Increase: 2024-11-12
Issue OwnerCurrent Issue Owner: @luacmartins
melvin-bot[bot] commented 1 week ago

Triggered auto assignment to @abekkala (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] commented 1 week ago

Triggered auto assignment to @Julesssss (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

melvin-bot[bot] commented 1 week ago

💬 A slack conversation has been started in #expensify-open-source

github-actions[bot] commented 1 week ago

:wave: Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.
Julesssss commented 1 week ago

Reproducible in production?: N/A - new feature, doesn't exist in prod

Demoting

melvin-bot[bot] commented 1 week ago

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

melvin-bot[bot] commented 1 week ago

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

Julesssss commented 1 week ago

Hi @IuliiaHerets, the reproduction steps aren't added yet. Could you please tag me when they are listed, thanks.

klajdipaja commented 6 days ago

Proposal

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

The status of the transaction does not show as paid when the transaction is part of a thread with multiple transaction and all transactions are paid.

What is the root cause of that problem?

To build the rows of the search results we call SearchUIUtils.getSections in this line https://github.com/klajdipaja/Expensify-App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/components/Search/index.tsx#L209. When the search is for all expenses it then calls: https://github.com/klajdipaja/Expensify-App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L212C10-L212C33.

In this function we try to resolve the action of the transaction in this line: https://github.com/klajdipaja/Expensify-App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L227 The root cause is then hidden on this block: https://github.com/klajdipaja/Expensify-App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L253-L256 because of this part of the conditon which is true: (isTransaction && !data[key].isFromOneTransactionReport) To sum it up, it seems like it has been the intended behaviour that when the transaction is part of multiple transaction report it will show the View action.

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

We should remove that part of the condition that checks for single transaction and make the conditon into this:

    if (!isTransaction && !isReportEntry(key)) {
        return CONST.SEARCH.ACTION_TYPES.VIEW;
    }

And rely on the action returned by the backend for this transaction instead of using the isSettled method which relies on the report that the transaction belongs to because the report does not have the right data to understand individual transaction status.

To do that we can at this line after when we resolved the transaction: https://github.com/klajdipaja/Expensify-App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L257. this block:

   if (transaction?.action === CONST.SEARCH.ACTION_TYPES.PAID) {
        return CONST.SEARCH.ACTION_TYPES.PAID;
    }

What alternative solutions did you explore? (Optional)

twilight2294 commented 6 days ago

Edited by proposal-police: This proposal was edited at 2024-11-12 14:35:16 UTC.

Proposal

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

Paid expenses do not have "Paid" label when the expenses are grouped expenses

What is the root cause of that problem?

When we get the actions, we check if the transaction is From One Transaction Report, for the bug description, it is false so we return the action to be CONST.SEARCH.ACTION_TYPES.VIEW:

https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L253-L255

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

Here, to fix this, we should also check whether the report is a isMoneyRequestReport and then only return the type as view, we do that but we do it below, after the above check:

https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L260-L263 So we should update the code as such:

function getAction(data: OnyxTypes.SearchResults['data'], key: string): SearchTransactionAction {
    const isTransaction = isTransactionEntry(key);
    const transaction = isTransaction ? data[key] : undefined;
    const report = isTransaction ? data[`${ONYXKEYS.COLLECTION.REPORT}${transaction?.reportID}`] : data[key];

    if ((!isTransaction && !isReportEntry(key)) || (isTransaction && !data[key].isFromOneTransactionReport && !ReportUtils.isMoneyRequestReport(report))) {
        return CONST.SEARCH.ACTION_TYPES.VIEW;
    }

This will make sure that we only return the type as view if the report is a money request report.

What alternative solutions did you explore? (Optional)

klajdipaja commented 6 days ago

In the Paid section we also have the View button displaying for transactions that are part of the group. I don't think that's what the reported issue is about by looking at the recording but if that is also part of the issue, here is what we would need to do to fix that:

We have a forced View mode in ActionCell.tsx when the parent and current transaction are both PAID.

https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/components/SelectionList/Search/ActionCell.tsx#L51

If we want to show the Paid checkmark we need to remove the shouldUseViewAction boolean. And also modify the condition here: https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/components/SelectionList/Search/ActionCell.tsx#L53 to remove the part that checks for the parent action:

    if (action === CONST.SEARCH.ACTION_TYPES.PAID || action === CONST.SEARCH.ACTION_TYPES.DONE) {
Nodebrute commented 6 days ago

Edited by proposal-police: This proposal was edited at 2024-11-12 14:54:39 UTC.

Proposal

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

Paid expenses do not have "Paid" label when the expenses are grouped expenses

What is the root cause of that problem?

For combined transactions, isFromOneTransactionReport will be false, which triggers the conditions below and causes View to be shown instead of Paid. https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L253-L255

but isFromOneTransactionReport was added for the below case where we don't want to show pay for individual transactions

Screenshot 2024-11-12 at 6 28 16 PM

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

  1. Remove (isTransaction && !data[key].isFromOneTransactionReport) https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L253

  2. Move this code block above this line https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L291-L297

  3. and at last change this line https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L261

    if (!ReportUtils.isMoneyRequestReport(report) || (isTransaction && !data[key].isFromOneTransactionReport)) {
        return CONST.SEARCH.ACTION_TYPES.VIEW;
    }

This solution will not break anything

https://github.com/user-attachments/assets/1558558d-9787-4377-9d51-cc982ca8fc0f

What alternative solutions did you explore? (Optional)

Alternatively, we can remove this (isTransaction && !data[key].isFromOneTransactionReport) https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L253

and after this line we can add

 if(isTransaction && !data[key].isFromOneTransactionReport){
    return CONST.SEARCH.ACTION_TYPES.VIEW;
  }

Solution 3 We can also change this https://github.com/Expensify/App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L252-L255

   if ((!isTransaction && !isReportEntry(key)) || (isTransaction && !data[key].isFromOneTransactionReport && !ReportUtils.isSettled(report) && !ReportUtils.isClosedReport(report))) {
        return CONST.SEARCH.ACTION_TYPES.VIEW;
    }
Anaslancer commented 6 days ago

Proposal

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

Search - Paid expenses do not have "Paid" label when the expenses are grouped expenses

What is the root cause of that problem?

Whenever we pay several transactions once, isFromOneTransactionReport of transaction is always false. Btw, in this below code, if isFromOneTransactionReport is false, getAction return 'view'. https://github.com/klajdipaja/Expensify-App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L253-L255 So we are watching the 'view' label in expenses search list.

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

If we want to see 'paid' at the moment, we should remove this below condition. https://github.com/klajdipaja/Expensify-App/blob/cd3f30f73a18c29532d6886b4bb3744fd700ab9d/src/libs/SearchUIUtils.ts#L253-L255 Here is the changed code.

    if (!isTransaction && !isReportEntry(key)) {
        return CONST.SEARCH.ACTION_TYPES.VIEW;
    }

What alternative solutions did you explore? (Optional)

N/A

Contributor details

Your Expensify account email: anasup1995@gmail.com Upwork Profile Link: https://www.upwork.com/freelancers/~01aff093c9a804b145

melvin-bot[bot] commented 6 days ago

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

IuliiaHerets commented 6 days ago

@Julesssss Added steps, sorry of this image

melvin-bot[bot] commented 6 days ago

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

luacmartins commented 6 days ago

I'll be handling this since I'm the author of the PR that caused the regression.

melvin-bot[bot] commented 6 days ago

Reviewing label has been removed, please complete the "BugZero Checklist".

melvin-bot[bot] commented 6 days ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.60-3 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-11-20. :confetti_ball:

melvin-bot[bot] commented 6 days ago

@Julesssss / @luacmartins @abekkala @Julesssss / @luacmartins The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

Julesssss commented 6 days ago

Thanks @luacmartins, usubscribing

luacmartins commented 5 days ago

Not ready to be paid, we just reverted the PR and I'll be working on a fix for this.

luacmartins commented 5 days ago

@abekkala I'll unassign you since we reverted the PR and fixed this issue. I'm keeping it open to make sure I address the issue in the v2 of my PR.

melvin-bot[bot] commented 5 days ago

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.0.61-3 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-11-21. :confetti_ball:

melvin-bot[bot] commented 5 days ago

@luacmartins @luacmartins The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]