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

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

Open
5 of 8 tasks
IuliiaHerets opened this issue Nov 12, 2024 · 25 comments
Open
5 of 8 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

@IuliiaHerets
Copy link

IuliiaHerets commented Nov 12, 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.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?

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

Screenshots/Videos

Bug6662249_1731401348204.20241112_164526.mp4

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
@IuliiaHerets IuliiaHerets added DeployBlockerCash This issue or pull request should block deployment Bug Something is broken. Auto assigns a BugZero manager. labels Nov 12, 2024
Copy link

melvin-bot bot commented Nov 12, 2024

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.

Copy link

melvin-bot bot commented Nov 12, 2024

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

@melvin-bot melvin-bot bot added the Daily KSv2 label Nov 12, 2024
Copy link

melvin-bot bot commented Nov 12, 2024

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

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Nov 12, 2024
Copy link
Contributor

👋 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
Copy link
Contributor

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

Demoting

@Julesssss Julesssss added External Added to denote the issue can be worked on by a contributor Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Nov 12, 2024
@melvin-bot melvin-bot bot changed the title Search - Paid expenses do not have "Paid" label when the expenses are grouped expenses [$250] Search - Paid expenses do not have "Paid" label when the expenses are grouped expenses Nov 12, 2024
Copy link

melvin-bot bot commented Nov 12, 2024

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

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

melvin-bot bot commented Nov 12, 2024

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

@Julesssss
Copy link
Contributor

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

@klajdipaja
Copy link
Contributor

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
Copy link
Contributor

twilight2294 commented Nov 12, 2024

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:

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

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:

// We don't need to run the logic if this is not a transaction or iou/expense report, so let's shortcircuit the logic for performance reasons
if (!ReportUtils.isMoneyRequestReport(report)) {
return CONST.SEARCH.ACTION_TYPES.VIEW;
}

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
Copy link
Contributor

klajdipaja commented Nov 12, 2024

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.

const shouldUseViewAction = action === CONST.SEARCH.ACTION_TYPES.VIEW || (parentAction === CONST.SEARCH.ACTION_TYPES.PAID && action === CONST.SEARCH.ACTION_TYPES.PAID);

If we want to show the Paid checkmark we need to remove the shouldUseViewAction boolean.
And also modify the condition here:

if ((parentAction !== CONST.SEARCH.ACTION_TYPES.PAID && action === CONST.SEARCH.ACTION_TYPES.PAID) || action === CONST.SEARCH.ACTION_TYPES.DONE) {

to remove the part that checks for the parent action:

    if (action === CONST.SEARCH.ACTION_TYPES.PAID || action === CONST.SEARCH.ACTION_TYPES.DONE) {

@Nodebrute
Copy link
Contributor

Nodebrute commented Nov 12, 2024

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.

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

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)

    if ((!isTransaction && !isReportEntry(key)) || (isTransaction && !data[key].isFromOneTransactionReport)) {

  2. Move this code block above this line

    if (IOU.canIOUBePaid(report, chatReport, policy, allReportTransactions, false, chatReportRNVP, invoiceReceiverPolicy)) {
    return CONST.SEARCH.ACTION_TYPES.PAY;
    }
    if (IOU.canApproveIOU(report, policy)) {
    return CONST.SEARCH.ACTION_TYPES.APPROVE;
    }

  3. and at last change this line

    if (!ReportUtils.isMoneyRequestReport(report)) {

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

This solution will not break anything

Screen.Recording.2024-11-12.at.7.53.20.PM.mov

What alternative solutions did you explore? (Optional)

Alternatively, we can remove this (isTransaction && !data[key].isFromOneTransactionReport)

if ((!isTransaction && !isReportEntry(key)) || (isTransaction && !data[key].isFromOneTransactionReport)) {

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

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

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

@Anaslancer
Copy link
Contributor

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: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01aff093c9a804b145

Copy link

melvin-bot bot commented Nov 12, 2024

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

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 Weekly KSv2 labels Nov 12, 2024
@melvin-bot melvin-bot bot changed the title [$250] [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses [HOLD for payment 2024-11-20] [$250] [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses Nov 13, 2024
Copy link

melvin-bot bot commented Nov 13, 2024

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

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 13, 2024
Copy link

melvin-bot bot commented Nov 13, 2024

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

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

Copy link

melvin-bot bot commented Nov 13, 2024

@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 Julesssss removed their assignment Nov 13, 2024
@Julesssss
Copy link
Contributor

Thanks @luacmartins, usubscribing

@luacmartins luacmartins added Daily KSv2 and removed Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production labels Nov 13, 2024
@luacmartins luacmartins changed the title [HOLD for payment 2024-11-20] [$250] [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses [$250] [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses Nov 13, 2024
@luacmartins
Copy link
Contributor

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

@luacmartins
Copy link
Contributor

@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 melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Nov 14, 2024
@melvin-bot melvin-bot bot changed the title [$250] [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses [HOLD for payment 2024-11-21] [$250] [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses Nov 14, 2024
Copy link

melvin-bot bot commented Nov 14, 2024

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

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

Copy link

melvin-bot bot commented Nov 14, 2024

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

@luacmartins luacmartins changed the title [HOLD for payment 2024-11-21] [$250] [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses [$250] [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses Nov 14, 2024
@luacmartins luacmartins removed the Awaiting Payment Auto-added when associated PR is deployed to production label Nov 14, 2024
@luacmartins luacmartins changed the title [$250] [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses [Search v1.2] - Paid expenses do not have "Paid" label when the expenses are grouped expenses Nov 14, 2024
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

9 participants