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

[Awaiting Payment] [$250] Split & Invoice -Preview shows empty receipt placeholder when there is no way to add a receipt #53524

Closed
8 tasks done
IuliiaHerets opened this issue Dec 4, 2024 · 39 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Dec 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: 9.0.71-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
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:

  1. Go to staging.new.expensify.com
  2. Go to workspace chat.
  3. Click + > Split expense > Manual.
  4. Submit a split manual expense.
  5. Note that the split preview has an empty receipt placeholder when there is no option to manually add a receipt to the split details.
  6. Go to FAB > Send invoice.
  7. Send an invoice to anyone.
  8. Note that the invoice preview also has an empty receipt placeholder when it is not possible to add a receipt to invoice.

Expected Result:

Empty receipt placeholder should not be displayed for split and invoice preview because there is no option to add a receipt in the first place.

Actual Result:

Empty receipt placeholder is displayed for split and invoice preview when there is no option to add a receipt in the first place.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6683822_1733279800030.receipt.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021864292349376469824
  • Upwork Job ID: 1864292349376469824
  • Last Price Increase: 2024-12-11
  • Automatic offers:
    • rojiphil | Reviewer | 105381426
    • Krishna2323 | Contributor | 105381429
Issue OwnerCurrent Issue Owner: @rojiphil
@IuliiaHerets IuliiaHerets added DeployBlockerCash This issue or pull request should block deployment Bug Something is broken. Auto assigns a BugZero manager. labels Dec 4, 2024
Copy link

melvin-bot bot commented Dec 4, 2024

Triggered auto assignment to @garrettmknight (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 melvin-bot bot added the Daily KSv2 label Dec 4, 2024
@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Dec 4, 2024
Copy link
Contributor

github-actions bot commented Dec 4, 2024

👋 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.

@garrettmknight garrettmknight added External Added to denote the issue can be worked on by a contributor and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Dec 4, 2024
Copy link

melvin-bot bot commented Dec 4, 2024

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

@melvin-bot melvin-bot bot changed the title Split & Invoice -Preview shows empty receipt placeholder when there is no way to add a receipt [$250] Split & Invoice -Preview shows empty receipt placeholder when there is no way to add a receipt Dec 4, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 4, 2024
Copy link

melvin-bot bot commented Dec 4, 2024

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

@melvin-bot melvin-bot bot added the Daily KSv2 label Dec 4, 2024
@garrettmknight
Copy link
Contributor

I don't think we'll need to block the deploy for this fix.

@garrettmknight garrettmknight moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Dec 4, 2024
@mkzie2
Copy link
Contributor

mkzie2 commented Dec 4, 2024

Edited by proposal-police: This proposal was edited at 2024-12-04 13:06:23 UTC.

Proposal

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

Empty receipt placeholder is displayed for split and invoice preview when there is no option to add a receipt in the first place.

What is the root cause of that problem?

We always show the ReportActionItemImages. When the transaction doesn't have the receipt, isEmptyReceipt is true and this component will display the ReceiptEmptyState

https://github.com/Expensify/App/blob/20b4c7db47969f7d2209f1c0b8fd765ce883f92c/src/components/ReportActionItem/ReportPreview.tsx#L475C1-L480C27

isEmptyReceipt={isEmptyReceipt}

if (isEmptyReceipt) {
return (
<ReceiptEmptyState
isThumbnail
onPress={onPress}

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

We should hide the receipt component if the transaction doesn't have the receipt and it's split in MoneyRequestPreviewContent

const shouldHideReceipt = !hasReceipt && isBillSplit;
{!shouldHideReceipt && (
    <ReportActionItemImages
        images={receiptImages}
        isHovered={isHovered || isScanning}
        size={1}
        onPress={shouldDisableOnPress ? undefined : onPreviewPressed}
    />
)}

And hide it in ReportPreview if it's an invoice

{!isInvoiceRoom && (
    <ReportActionItemImages
        images={lastThreeReceipts}
        total={allTransactions.length}
        size={CONST.RECEIPT.MAX_REPORT_PREVIEW_RECEIPTS}
        onPress={openReportFromPreview}
    />
)}

https://github.com/Expensify/App/blob/20b4c7db47969f7d2209f1c0b8fd765ce883f92c/src/components/ReportActionItem/ReportPreview.tsx#L475C1-L480C27

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

It's a UI bug and I don't think we need a test case here.

Or we can create a util shouldHideReceipt, use it here and add some tests to verify that it works as expected for some cases:

  • The transaction has receipt

  • The transaction has no receipt and the the iou report is money request report or it's a track expense action

  • The transaction has no receipt and it's a split bill or send invoice

What alternative solutions did you explore? (Optional)

@rojiphil
Copy link
Contributor

rojiphil commented Dec 4, 2024

@mkzie2 Thanks for your proposal. The RCA is correct as we are showing the receipt preview without checking if we can show receipt preview or not. However, instead of focusing on the condition to show, can you please update the proposal to focus on when not to show (i.e. when split and invoice preview).

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 4, 2024

@rojiphil Updated my proposal with the condition to hide the receipt.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Dec 4, 2024

Edited by proposal-police: This proposal was edited at 2024-12-04 14:28:36 UTC.

Proposal

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

Split & Invoice -Preview shows empty receipt placeholder when there is no way to add a receipt

What is the root cause of that problem?

  • We try to get the receipts of the last three transactions and if the transaction does not have any receipt, we return {isEmptyReceipt: true} from getThumbnailAndImageURIs and when the array is passed to ReportActionItemImages the ReportActionItemImages will render an empty placeholder if isEmptyReceipt is true
    const lastThreeTransactions = allTransactions.slice(-3);
    const lastThreeReceipts = lastThreeTransactions.map((transaction) => ({...ReceiptUtils.getThumbnailAndImageURIs(transaction), transaction}));

    <ReportActionItemImages
    images={lastThreeReceipts}
    total={allTransactions.length}
    size={CONST.RECEIPT.MAX_REPORT_PREVIEW_RECEIPTS}
    onPress={openReportFromPreview}
    />

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

  • We should a the same condition used in MoneyRequestView to show the empty state and using the condition we will filter out the transactions which doesn't have an receipt and receipt can't be updated/added to it.
    const isReceiptAllowed = !isPaidReport && !isInvoice;
    const shouldShowReceiptEmptyState =
    isReceiptAllowed && !hasReceipt && !isApproved && !isSettled && (canEditReceipt || isAdmin || isApprover || isRequestor) && (canEditReceipt || ReportUtils.isPaidGroupPolicy(report));
    // This is just pseudocode, we can refactor this in the PR.
    const isInvoice = ReportUtils.isInvoiceReport(iouReport);
    const canUserPerformWriteAction = !!ReportUtils.canUserPerformWriteAction(iouReport);
    const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN;
    const isApprover = ReportUtils.isMoneyRequestReport(iouReport) && iouReport?.managerID !== null && session?.accountID === iouReport?.managerID;
    const currentUserPersonalDetails = useCurrentUserPersonalDetails();
    const isRequestor = currentUserPersonalDetails.accountID === action?.actorAccountID;
    const canEditReceipt = canUserPerformWriteAction && ReportUtils.canEditFieldOfMoneyRequest(action, CONST.EDIT_REQUEST_FIELD.RECEIPT);

    const isSettled = ReportUtils.isSettled(iouReport?.reportID);
    const shouldShowReceiptEmptyState =
        !isInvoice && !isApproved && !isSettled && (canEditReceipt || isAdmin || isApprover || isRequestor) && (canEditReceipt || ReportUtils.isPaidGroupPolicy(iouReport));
    const lastThreeTransactions = allTransactions.slice(-3).filter((t) => TransactionUtils.hasReceipt(t) || shouldShowReceiptEmptyState);
     const lastThreeReceipts = lastThreeTransactions.map((transaction) => ({...ReceiptUtils.getThumbnailAndImageURIs(transaction), transaction}));
  • We will hide ReportActionItemImages if lastThreeReceipts length is 0 and in MoneyRequestPreviewContent we will return empty array when we shouldShowReceiptEmptyState condition is not matched and similarly we will not render ReportActionItemImages when receiptImages length is 0.
    const receiptImages = [{...ReceiptUtils.getThumbnailAndImageURIs(transaction), transaction}];

    <ReportActionItemImages
    images={receiptImages}
    isHovered={isHovered || isScanning}
    size={1}
    onPress={shouldDisableOnPress ? undefined : onPreviewPressed}
    />
  • We can create a util function for getting the value of shouldShowReceiptEmptyState because it will be used in multiple places.
  • We also need to do the same changes in MoneyRequestPreviewContent.tsx

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


  • If we add a new util function for checking if we can show the receipt empty view or not then we can add some tests for the util function with some different type of IOU reports.

What alternative solutions did you explore? (Optional)

@Krishna2323
Copy link
Contributor

@rojiphil could you please check my proposal? Thanks!

@rojiphil
Copy link
Contributor

rojiphil commented Dec 4, 2024

@mkzie2 @Krishna2323 Thanks both for your proposals. However, your proposals lack clarity on both the root cause and the solution and is unacceptable to me in its current form. Can you please be more precise with respect to the root cause and solution?

@Krishna2323
Copy link
Contributor

@rojiphil, Proposal Updated.

@mkzie2
Copy link
Contributor

mkzie2 commented Dec 5, 2024

Updated proposal.

Copy link

melvin-bot bot commented Dec 18, 2024

📣 @rojiphil 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Dec 18, 2024

📣 @Krishna2323 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

Copy link

melvin-bot bot commented Dec 18, 2024

@garrettmknight @rojiphil @lakchote @Krishna2323 this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@Krishna2323
Copy link
Contributor

PR will be up within 24 hours.

@Krishna2323
Copy link
Contributor

@rojiphil PR is ready for review ^, sorry for delay🙏🏻

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Jan 15, 2025
Copy link

melvin-bot bot commented Jan 15, 2025

This issue has not been updated in over 15 days. @garrettmknight, @rojiphil, @lakchote, @Krishna2323 eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@garrettmknight
Copy link
Contributor

Still working on the PR.

@garrettmknight
Copy link
Contributor

I just chatted with @dannymcclain about this. It turns out this is an intentional result of our design framework, and it's going to change in the near future with a few other projects.

Sorry for the confusion! I'll still pay out full for this since there was so much work done. @Krishna2323 please close your PR when you get a chance.

@garrettmknight garrettmknight added Daily KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Reviewing Has a PR in review Weekly KSv2 labels Feb 3, 2025
@garrettmknight garrettmknight changed the title [$250] Split & Invoice -Preview shows empty receipt placeholder when there is no way to add a receipt [Awaiting Payment] [$250] Split & Invoice -Preview shows empty receipt placeholder when there is no way to add a receipt Feb 3, 2025
@Krishna2323
Copy link
Contributor

@garrettmknight, I have closed the PR, thanks for confirmation and payment🙏🏻.

@garrettmknight
Copy link
Contributor

Payment Summary:

@github-project-automation github-project-automation bot moved this from Bugs and Follow Up Issues to Done in [#whatsnext] #expense Feb 3, 2025
@melvin-bot melvin-bot bot removed the Overdue label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests

6 participants