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

[LOW] [Splits] IOU - IOU becomes paid while receipt is scanning #33972

Closed
6 tasks done
lanitochka17 opened this issue Jan 4, 2024 · 85 comments
Closed
6 tasks done

[LOW] [Splits] IOU - IOU becomes paid while receipt is scanning #33972

lanitochka17 opened this issue Jan 4, 2024 · 85 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Internal Requires API changes or must be handled by Expensify staff Monthly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 4, 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: 1.4.21-1
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
Expensify/Expensify Issue URL:
Issue reported by: Applause - Internal Team
Slack conversation:

Action Performed:

  1. Send an IOU from Account A to Account B
  2. Open Account B and send a receipt IOU
  3. While the IOU is scanning click on pay elsewhere
  4. Click on the preview component to open the IOU conversation and observe the IOU while receipt is being scanned

Expected Result:

Receipt IOU should not be marked as paid

Actual Result:

The receipt IOU is marked as paid before the receipt is done scanning and before account B marks it as paid

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • Windows: Chrome
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6332407_1704391663502.receiptscanpaid.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a008da44d804c493
  • Upwork Job ID: 1742972707793920000
  • Last Price Increase: 2024-01-25
Issue OwnerCurrent Issue Owner: @youssef-lr
@lanitochka17 lanitochka17 added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 4, 2024
Copy link

melvin-bot bot commented Jan 4, 2024

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

@melvin-bot melvin-bot bot changed the title IOU - IOU becomes paid while receipt is scanning [$500] IOU - IOU becomes paid while receipt is scanning Jan 4, 2024
Copy link

melvin-bot bot commented Jan 4, 2024

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

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

melvin-bot bot commented Jan 4, 2024

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

Copy link

melvin-bot bot commented Jan 4, 2024

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

@abzokhattab
Copy link
Contributor

abzokhattab commented Jan 4, 2024

Proposal

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

Currently, if you click the "pay" button while a receipt is still scanning, the receipt gets incorrectly marked as paid even though the scan is not finished.

What is the root cause of that problem?

The problem occurs because we don't exclude receipts/reports that are still scanning when you press the "pay" button.

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

We have two options to solve this:

  1. Modify the code to hide the pay button while a receipt is being scanned. We need to add a condition && !isScanning to the relevant code sections. This change will prevent the pay button from appearing if a receipt is still scanning.
   const shouldShowPayButton = useMemo(
        () => isPayer && !isDraftExpenseReport && !iouSettled && !props.iouReport.isWaitingOnBankAccount && reimbursableSpend !== 0 && !iouCanceled && !isScanning,
        [isPayer, isDraftExpenseReport, iouSettled, props.iouReport.isWaitingOnBankAccount, reimbursableSpend, iouCanceled, isScanning],
    );

() => isPayer && !isDraftExpenseReport && !iouSettled && !props.iouReport.isWaitingOnBankAccount && reimbursableSpend !== 0 && !iouCanceled,
[isPayer, isDraftExpenseReport, iouSettled, reimbursableSpend, iouCanceled, props.iouReport],
);
const shouldShowApproveButton = useMemo(() => {

and here as well

const shouldShowPayButton = useMemo(
() => isPayer && !isDraft && !isSettled && !moneyRequestReport.isWaitingOnBankAccount && reimbursableTotal !== 0 && !ReportUtils.isArchivedRoom(chatReport),
[isPayer, isDraft, isSettled, moneyRequestReport, reimbursableTotal, chatReport],
);

  1. OR keep the pay button visible, but modify the backend to not mark scanning receipts as paid. For this, we need to introduce a new parameter excludedReportIDs. This will be an array containing the IDs of receipts that are still scanning. However, this requires creating a new parameter that currently doesn't exist, meaning collaboration with the backend team is needed. then should be used in the getPayMoneyRequest function

function payMoneyRequest(paymentType, chatReport, iouReport) {

@Tony-MK
Copy link
Contributor

Tony-MK commented Jan 5, 2024

Proposal

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

IOU becomes paid while the receipt is scanning.

What is the root cause of that problem?

The ReportPreview, MoneyReportView, MoneyRequestPreview and MoneyRequestView components all use the ReportUtils.isSettled function to determine the value of isSettled or iouSettled in ReportPreview.

For IOUs paid elsewhere, ReportUtils.isSettled only checks if report.statusNum === CONST.REPORT.STATUS.REIMBURSED, even if a receipt of a transaction is being scanned.

Therefore, the root cause of the problem is that we solely, use isSettled or iouSettled to determine whether to show if the IOU is paid or not.

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

We need to add a condition in all of the respective components to check if a transaction has a receipt that is being scanned. The condition varies from component to component. With this condition, we can properly display the paid checkmark icons when a receipt is being scanned.

  1. ReportPreview

For ReportPreview, iouSettled is used in many places, hence we should only change the applicable places to avoid regressions.

i) Checkmark Icon

{ReportUtils.isSettled(props.iouReportID) && (

{ReportUtils.isSettled(props.iouReportID) && !numberOfScanningReceipts && (

Screenshot 2024-01-13 at 05 15 14

ii) 'Paid' Text

Unsure if this should be changed, and if so how because I don't think it is expected to look like below.

If we a changing the text, should the text in the MoneyRequestHeader and MoneyReportHeader components be changed as well?

if (iouSettled || props.iouReport.isWaitingOnBankAccount) {

if (iouSettled && !numberOfScanningReceipts || props.iouReport.isWaitingOnBankAccount) {

Screenshot 2024-01-13 at 05 23 38

  1. MoneyRequestView
    const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID);
const isSettled = ReportUtils.isSettled(moneyRequestReport.reportID) && (!TransactionUtils.hasReceipt(transaction) || !TransactionUtils.isReceiptBeingScanned(transaction));

Screenshot 2024-01-13 at 05 27 07

  1. MoneyRequestPreview
    const isSettled = ReportUtils.isSettled(props.iouReport.reportID);
const isSettled = ReportUtils.isSettled(props.iouReport.reportID) && !isScanning;

Screenshot 2024-01-13 at 05 10 58

  1. MoneyReportView (Unsure if we should apply this condition to the checkmark)

https://github.com/Expensify/App/blob/744e35c85157ecef9cdfab81a0ab56891dc507f9/src/components/ReportActionItem/MoneyReportView.js#L33

const isSettled = ReportUtils.isSettled(report.reportID) && !ReportUtils.getTransactionsWithReceipts(report.iouReportID).some((transaction) => TransactionUtils.isReceiptBeingScanned(transaction));

Screenshot 2024-01-13 at 05 14 10

Optional for Granularity

These suggestions are to reduce the chances that the introduced condition will create a regression.

  1. Use of TransactionUtils.isAmountMissing(transaction) in the condition so isSettled is true when the amount is manually entered later.

  2. We can find the reportAction which has originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY && originalMessage.paymentType === CONST.IOU.PAYMENT_TYPE.ELSEWHERE in the condition to apply the created condition for determining isSettled only when the IOU is paid elsewhere and not with other methods.

What alternative solutions did you explore? (Optional)

This simple solution will handle all places in which the bug applies but is risky.

We could change the ReportUtils.isSettled function but I am afraid it may break other functions and components that depend on ReportUtils.isSettled .

However, if you don't mind we can add an extra condition like previously mentioned to the ReportUtils.isSettled function.

@melvin-bot melvin-bot bot added the Overdue label Jan 8, 2024
Copy link

melvin-bot bot commented Jan 8, 2024

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

@garrettmknight
Copy link
Contributor

@Ollyws can you please review the proposals so far?

@melvin-bot melvin-bot bot removed the Overdue label Jan 8, 2024
Copy link

melvin-bot bot commented Jan 11, 2024

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

@melvin-bot melvin-bot bot added the Overdue label Jan 11, 2024
@Ollyws
Copy link
Contributor

Ollyws commented Jan 11, 2024

Thanks for the proposals but it seems both may be unclear about the issue.
The problem is not that the pay button is being displayed, it should be displayed as there are other requests and as far as I can see it is not shown if there is only a reciept being scanned.
The problem is that selecting pay elsewhere marks everything as paid including the reciept (which is in the process of scanning).

@melvin-bot melvin-bot bot removed the Overdue label Jan 11, 2024
@Tony-MK
Copy link
Contributor

Tony-MK commented Jan 13, 2024

Thank you, @Ollyws, for reviewing my proposal, and I apologize for failing to grasp the expected result.

I have updated my proposal based on your comments at #33972 (comment).

However, there are some questions which I would appreciate if you answer.

Thank you.

@melvin-bot melvin-bot bot added the Overdue label Jan 13, 2024
@abzokhattab
Copy link
Contributor

Thanks @Ollyws added a second solution to avoid marking scanning receipts as paid.

@Ollyws
Copy link
Contributor

Ollyws commented Jan 15, 2024

Will review asap.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Jan 15, 2024
@garrettmknight
Copy link
Contributor

@Ollyws can you review the updates when you get a chance?

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

melvin-bot bot commented Jan 18, 2024

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

@melvin-bot melvin-bot bot added the Overdue label May 13, 2024
Copy link

melvin-bot bot commented May 13, 2024

@garrettmknight, @youssef-lr, @Ollyws Whoops! This issue is 2 days overdue. Let's get this updated quick!

@youssef-lr
Copy link
Contributor

No update yet, still planning to get to this.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels May 15, 2024
Copy link

melvin-bot bot commented May 20, 2024

@garrettmknight, @youssef-lr, @Ollyws Huh... This is 4 days overdue. Who can take care of this?

@youssef-lr
Copy link
Contributor

I'll have time for this next week.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels May 21, 2024
Copy link

melvin-bot bot commented May 27, 2024

@garrettmknight, @youssef-lr, @Ollyws Huh... This is 4 days overdue. Who can take care of this?

@youssef-lr
Copy link
Contributor

No update yet, I'm focusing on fixing a few bugs for split affecting quality

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels May 29, 2024
Copy link

melvin-bot bot commented Jun 3, 2024

@garrettmknight, @youssef-lr, @Ollyws Eep! 4 days overdue now. Issues have feelings too...

Copy link

melvin-bot bot commented Jun 5, 2024

@garrettmknight, @youssef-lr, @Ollyws Still overdue 6 days?! Let's take care of this!

@youssef-lr
Copy link
Contributor

No update yet

@melvin-bot melvin-bot bot removed the Overdue label Jun 5, 2024
@saracouto saracouto added Monthly KSv2 and removed Daily KSv2 labels Jun 7, 2024
@melvin-bot melvin-bot bot added the Overdue label Jul 8, 2024
@youssef-lr
Copy link
Contributor

Same

@melvin-bot melvin-bot bot removed the Overdue label Jul 10, 2024
@melvin-bot melvin-bot bot added the Overdue label Aug 12, 2024
@youssef-lr
Copy link
Contributor

I think this should be fixed since we started moving scanning expenses to new reports when a report is paid. Going to try reproducing this week or the next one.

@melvin-bot melvin-bot bot removed the Overdue label Aug 13, 2024
@melvin-bot melvin-bot bot added the Overdue label Sep 16, 2024
@youssef-lr
Copy link
Contributor

This is fixed.

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

No branches or pull requests

10 participants