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] Invoice - Receiver can pay invoice as business in archived invoice room which causes error #55067

Open
8 tasks done
IuliiaHerets opened this issue Jan 10, 2025 · 5 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Jan 10, 2025

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.83-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Mac 15.0 / Chrome
App Component: Money Requests

Action Performed:

Precondition:

  • Invoices feature is enabled.
  • Invoice receiver does not have any workspace.
  1. Go to staging.new.expensify.com
  2. Go to FAB > Send invoice.
  3. Send an invoice to anyone.
  4. Delete the workspace after sending the invoice.
  5. As invoice receiver, go to the archived invoice room.
  6. Click on the invoice preview.
  7. Click Pay button and pay as business.
  8. Go to Account settings > Workspaces.
  9. Click on the newly created workspace.

Expected Result:

In Step 8, there should be no pay button if paying an invoice as business is not possible in archived invoice room.

Actual Result:

In Step 8, there is an option to pay the invoice as business in archived invoice room. Error shows up when trying to pay it as business.
In Step 9, new workspace is created from paying as business which shows RBR in Categories page.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6710957_1736513973359.20250110_205026.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021877779263396055998
  • Upwork Job ID: 1877779263396055998
  • Last Price Increase: 2025-01-10
Issue OwnerCurrent Issue Owner: @abdulrahuman5196
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 10, 2025
Copy link

melvin-bot bot commented Jan 10, 2025

Triggered auto assignment to @sakluger (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.

@NJ-2020
Copy link
Contributor

NJ-2020 commented Jan 10, 2025

Proposal

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

Invoice - Receiver can pay invoice as business in archived invoice room which causes error

What is the root cause of that problem?

Right here we do not check for archived policy

const shouldShowSettlementButton =
(shouldShowPayButton || shouldShowApproveButton) && !hasAllPendingRTERViolations && !shouldShowExportIntegrationButton && !shouldShowBrokenConnectionViolation;

and same for moneyreportheader

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

We should display the settlement button if the room is not archived by using && !isArchivedReport

const shouldShowSettlementButton =
(shouldShowPayButton || shouldShowApproveButton) && !hasAllPendingRTERViolations && !shouldShowExportIntegrationButton && !shouldShowBrokenConnectionViolation;

we will do the same way for moneyreportheader
const isArchivedReport = ReportUtils.isArchivedRoomWithID(moneyRequestReport?.reportID);

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

What alternative solutions did you explore? (Optional)

@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Jan 10, 2025
@melvin-bot melvin-bot bot changed the title Invoice - Receiver can pay invoice as business in archived invoice room which causes error [$250] Invoice - Receiver can pay invoice as business in archived invoice room which causes error Jan 10, 2025
Copy link

melvin-bot bot commented Jan 10, 2025

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

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

melvin-bot bot commented Jan 10, 2025

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

@Tony-MK
Copy link
Contributor

Tony-MK commented Jan 10, 2025

Proposal

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

Invoice - Receiver can pay invoice as business in archived invoice room which causes error

What is the root cause of that problem?

In the canIOUBePaid function, an archived invoice report will return true because we do not check if the report is archived when we check for iouSettled.

App/src/libs/actions/IOU.ts

Lines 7360 to 7368 in 04d54df

if (ReportUtils.isInvoiceReport(iouReport)) {
if (iouSettled) {
return false;
}
if (chatReport?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL) {
return chatReport?.invoiceReceiver?.accountID === userAccountID;
}
return (invoiceReceiverPolicy ?? PolicyUtils.getPolicy(chatReport?.invoiceReceiver?.policyID))?.role === CONST.POLICY.ROLE.ADMIN;
}

Normally, isChatReportArchived would be checked at the end of the function but since the report is an invoice the function doesn't reach here.

App/src/libs/actions/IOU.ts

Lines 7387 to 7398 in 04d54df

return (
isPayer &&
!isOpenExpenseReport &&
!iouSettled &&
!iouReport?.isWaitingOnBankAccount &&
reimbursableSpend !== 0 &&
!isChatReportArchived &&
!isAutoReimbursable &&
(!shouldBeApproved || !shouldCheckApprovedState) &&
!isPayAtEndExpenseReport
);
}

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

We should use isChatReportArchived to check if the workspace is archived in the condition below.

App/src/libs/actions/IOU.ts

Lines 7361 to 7362 in 04d54df

if (iouSettled) {
return false;

if (iouSettled || isChatReportArchived) {

Screenshot 2025-01-11 at 02 33 22

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

Since no tests exist for canIOUBePaid, we should create one by creating random reports and policies and testing its outcome.

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. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
Status: No status
Development

No branches or pull requests

5 participants