Invoices - Export button is present in invoice details RHP but invoice cannot be exported
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.73-6 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: Exp Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team
Action Performed:
Precondition:
- Workspace is connected to QBO
- Go to staging.new.expensify.com
- Go to FAB > Send invoice
- Enter amount and select a participant
- Select the workspace connected to QBO as the sender
- Send the invoice
- Click on the invoice preview.
- Click report header.
- Click Export.
- Note that Export option is available but the option does not allow to export invoices.
- Have the invoice receiver pay the invoice.
- Repeat Step 6 to 8.
Expected Result:
Export button should be removed from report details RHP if invoices cannot be exported to QBO.
Actual Result:
Export button is present in report details RHP but it does not allow invoices to be exported.
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/c1add3a4-1aa1-49b9-9ea7-d678de7f5bd5
Triggered auto assignment to @VictoriaExpensify (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.
vquraishi Your proposal will be dismissed because you did not follow the proposal template.
Edited by proposal-police: This proposal was edited at 2024-12-10 12:36:20 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Invoices - Export button is present in invoice details RHP but invoice cannot be exported
What is the root cause of that problem?
We are not checking for canBeExported when showing the menu here
https://github.com/Expensify/App/blob/219dabf6a0a907f16aef543306c78fab172c3c4b/src/pages/ReportDetailsPage.tsx#L473-L476
What changes do you think we should make in order to solve the problem?
We should display the menu if the report can be exported with the function we use here https://github.com/Expensify/App/blob/219dabf6a0a907f16aef543306c78fab172c3c4b/src/pages/home/report/ReportDetailsExportPage.tsx#L41
if (policy && connectedIntegration && isPolicyAdmin && !isSingleTransactionView && isExpenseReport && ReportUtils.canBeExported(report)) {
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
We can make a test for our ReportDetailsPage with a report that cannot be exported (for instance, invoice report as in this case) and then assert that export menu is not included in the menu items
What alternative solutions did you explore? (Optional)
Alternatively, if we want to allow exporting for invoices we should replace isExpenseReport check here with isMoneyRequestReport || isInvoiceReport
https://github.com/Expensify/App/blob/50c1db81004285968c6388bc941860f554d411e6/src/libs/ReportUtils.ts#L8446
return (isExpenseReport(report) || isInvoiceReport(report)) && isCorrectState;
And make the condition in report details page consistent with it so we should update the condition here https://github.com/Expensify/App/blob/70b92384ba20afcb031f925dac8e7f50b79c4dd0/src/pages/ReportDetailsPage.tsx#L489
if (policy && connectedIntegration && isPolicyAdmin && !isSingleTransactionView && (isExpenseReport(report) || isInvoiceReport)) {
Edited by proposal-police: This proposal was edited at 2024-12-10 13:07:50 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Export button is present in invoice details RHP but invoice cannot be exported
What is the root cause of that problem?
We use existing isExpenseReport const to check and it is true if isInvoiceReport is true
https://github.com/Expensify/App/blob/70b92384ba20afcb031f925dac8e7f50b79c4dd0/src/pages/ReportDetailsPage.tsx#L489
https://github.com/Expensify/App/blob/219dabf6a0a907f16aef543306c78fab172c3c4b/src/pages/ReportDetailsPage.tsx#L140
What changes do you think we should make in order to solve the problem?
Use ReportUtils.isExpenseReport(report) instead of the existing isExpenseReport const
https://github.com/Expensify/App/blob/70b92384ba20afcb031f925dac8e7f50b79c4dd0/src/libs/ReportUtils.ts#L874-L876
if (policy && connectedIntegration && isPolicyAdmin && !isSingleTransactionView && ReportUtils.isExpenseReport(report)) {
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Create a test case with invoice report and assert that the export button is not present if the report is invoice
What alternative solutions did you explore? (Optional)
Or change this to the following
const isExpenseReport = ReportUtils.isExpenseReport(report);
use useMemo if needed
Hmm I don't understand this issue. Why wouldn't we want invoices to be exported? Invoices can, and should be, exported to QBO.
@VictoriaExpensify Sure, we want invoices to be exported. But when we click Export, we see Not ready to export, so impossible to do it
Added alternative approach to allow invoice report exporting
@IuliiaHerets I actually think it's fine for the export button to be present here. The message shown is very clear to the user why it cannot be exported, and I think removing the export button would create more confusion for the customer.
I don't think we need to do anything here