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

[HOLD for payment 2024-06-11] Send invoice - App crashes when sending invoice via link when there's no workspace #41305

Closed
6 tasks done
izarutskaya opened this issue Apr 30, 2024 · 64 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 Engineering External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Apr 30, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.4.68-0
Reproducible in staging?: Y
Reproducible in production?: N
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

Precondition:

  • User has no workspace.
  1. Launch New Expensify app.
  2. Copy send invoice link from web (https://staging.new.expensify.com/create/invoice/start/1/7783051691252045).
  3. Paste the link on mobile app.
  4. Click on the link.
  5. Enter amount > Next.
  6. Select participant.

Expected Result:

In Step 4, app should display not here link.

Actual Result:

In Step 4, user is able to proceed with send invoice flow.
After selecting participant in Step 6, app crashes. On web, it shows console error.

Workaround:

Unknown

Platforms:

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

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

Screenshots/Videos

Bug6466241_1714456420346.Screen_Recording_20240430_134316_One_UI_Home.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @rojiphil
@izarutskaya izarutskaya added DeployBlockerCash This issue or pull request should block deployment Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 30, 2024
Copy link

melvin-bot bot commented Apr 30, 2024

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

Copy link

melvin-bot bot commented Apr 30, 2024

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

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Apr 30, 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.

@izarutskaya
Copy link
Author

@puneetlath I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors.

@izarutskaya
Copy link
Author

We think this issue might be related to the #vip-bills.

@izarutskaya
Copy link
Author

Production

Screen_Recording_20240430_115352_New.Expensify.mp4

@puneetlath puneetlath removed the DeployBlockerCash This issue or pull request should block deployment label Apr 30, 2024
@puneetlath
Copy link
Contributor

I don't think this needs to be a deploy blocker, but @VickyStash do you want to look into it?

@VickyStash
Copy link
Contributor

@puneetlath I'll take a look in a bit 👌 But I'm not sure if I can deal with it today (I'm going to be OOO 1st-8th of May)

@puneetlath puneetlath added Weekly KSv2 and removed Hourly KSv2 labels Apr 30, 2024
@puneetlath
Copy link
Contributor

Ok, I'm going to assign @cristipaval and @davidcardoza for now to let y'all figure out how to handle 😄

@danielrvidal
Copy link
Contributor

This feels like a good cleanup issue so marking it as Low. I can't imagine a user actually pasting in the send invoice URL in a real flow. So I think if you have other urgent work, I'd prioritize that @VickyStash. But I agree we should clean this up.

@VickyStash
Copy link
Contributor

NOTE: I'll be OOO 1-8th of May 🌴

@davidcardoza
Copy link
Contributor

@cristipaval can we source another contributor to lead this?

@ShridharGoel
Copy link
Contributor

ShridharGoel commented May 4, 2024

Proposal

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

App crashes when sending invoice via link when there's no workspace.

What is the root cause of that problem?

If there's no workspace, then primaryPolicy becomes undefined and app crashes when using primaryPolicy.id.

if (iouType === CONST.IOU.TYPE.INVOICE) {
const primaryPolicy = Policy.getPrimaryPolicy(activePolicyID);
newParticipants.push({
policyID: primaryPolicy.id,
isSender: true,
selected: false,
iouType,
});
}

The logic in isAllowedToCreateRequest is flawed, but it just checks canSendInvoice with an || condition, so if one of the other conditions become true then the value will become true and FullPageNotFoundView will not show.

const isAllowedToCreateRequest = isEmptyObject(report?.reportID) || ReportUtils.canCreateRequest(report, policy, iouType) || PolicyUtils.canSendInvoice(allPolicies);

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

Option 1:

Update the isAllowedToCreateRequest condition to below:

const isAllowedToCreateRequest = (isEmptyObject(report?.reportID) || ReportUtils.canCreateRequest(report, policy, iouType)) && (iouType === CONST.IOU.TYPE.INVOICE ? PolicyUtils.canSendInvoice(allPolicies) : true);

Also, wrap the existing code in MoneyTemporaryForRefactorRequestParticipantsSelector with check to ensure that the primaryPolicy.id is used only if primaryPolicy is defined:

if (primaryPolicy) {
    newParticipants.push({
        policyID: primaryPolicy.id,
        isSender: true,
        selected: false,
        iouType,
    });
}

To add the same functionality in other pages, we'll need to add FullPageNotFoundView in pages like IOURequestStepConfirmation, IOURequestStepParticipants, IOURequestStepAmount, IOURequestStepDescription etc,. as well with the same condition as the start page. We can move isAllowedToCreateRequest logic to a common utils method. We'll need to pass the report, policy, iouType and allPolicies to the common method.

(Code can be polished)

const canNotAccessRequestPage = (report, policy, iouType, allPolicies) => {
        return !IOUUtils.isValidMoneyRequestType(iouType) || !((isEmptyObject(report?.reportID) || ReportUtils.canCreateRequest(report, policy, iouType)) && (iouType === CONST.IOU.TYPE.INVOICE ? PolicyUtils.canSendInvoice(allPolicies) : true));
}
<FullPageNotFoundView shouldShow={canNotAccessRequestPage(report, policy, iouType, allPolicies)}>

</FullPageNotFoundView>

Option 2:

We can use this in WithWritableReportOrNotFound, so we will not need to add the condition check in all types of pages.

if (iouTypeParamIsInvalid || !canUserPerformWriteAction || canNotAccessRequestPage(report, props.policy, route.params?.iouType, props.allPolicies)) {
    return <FullPageNotFoundView shouldShow />;
}

This would let us have the logic in a single place for all the steps.

We'll get policy and allPolicies via onyx:

policy: {
    key: ({report, transaction}) => `${ONYXKEYS.COLLECTION.POLICY}${IOU.getIOURequestPolicyID(transaction, report)}`,
},
allPolicies: {
    key: ONYXKEYS.COLLECTION.POLICY,
},

We need to update WithWritableReportOrNotFoundOnyxProps as well.

Note that though start page doesn't have WithWritableReportOrNotFound but it uses the IOURequestStepAmount page which contains WithWritableReportOrNotFound. We can discuss if we want to keep FullPageNotFoundView in start page or not.

We can also move this logic to a new WithAccessableRequestOrNotFound.

Then, while exporting, it will be like this:

const IOURequestStepAmountWithCurrentUserPersonalDetails = withCurrentUserPersonalDetails(IOURequestStepAmountWithOnyx);

const IOURequestStepAmountWithWritableReportOrNotFound = withWritableReportOrNotFound(IOURequestStepAmountWithCurrentUserPersonalDetails, true);

const IOURequestStepAmountWithFullTransactionOrNotFound = withFullTransactionOrNotFound(IOURequestStepAmountWithWritableReportOrNotFound);

const IOURequestStepAmountWithAccessableRequestOrNotFound = withAccessableRequestOrNotFound(IOURequestStepAmountWithFullTransactionOrNotFound);

export default IOURequestStepAmountWithAccessableRequestOrNotFound;

Also, wrap the existing code in MoneyTemporaryForRefactorRequestParticipantsSelector with check to ensure that the primaryPolicy.id is used only if primaryPolicy is defined:

if (primaryPolicy) {
    newParticipants.push({
        policyID: primaryPolicy.id,
        isSender: true,
        selected: false,
        iouType,
    });
}

@cristipaval
Copy link
Contributor

I think we want to completely hide this link now that we support invoices on NewDot. @davidcardoza could you please confirm?

I thought beta is referred to by this. If not, @cristipaval @shubham1206agra Can you clarify what it means by that comment?

I am sorry for the confusion that I created with that comment. I misunderstood the repro steps.

@cristipaval
Copy link
Contributor

I like the @tienifr solution to expand the AccessOrNotFoundWrapper and make it work for our current use case. I agree that it is cleaner and handles all pages of the flow automatically. Also, if we add a new page to the flow, it will be automatically handled, making the solution more scalable.

@cristipaval cristipaval assigned tienifr and unassigned VickyStash May 6, 2024
@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label May 6, 2024
@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels May 8, 2024
@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels May 31, 2024
Copy link

melvin-bot bot commented May 31, 2024

This issue has not been updated in over 15 days. @davidcardoza, @cristipaval, @shubham1206agra, @tienifr 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!

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Monthly KSv2 labels Jun 4, 2024
@melvin-bot melvin-bot bot changed the title Send invoice - App crashes when sending invoice via link when there's no workspace [HOLD for payment 2024-06-11] Send invoice - App crashes when sending invoice via link when there's no workspace Jun 4, 2024
Copy link

melvin-bot bot commented Jun 4, 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 Jun 4, 2024
Copy link

melvin-bot bot commented Jun 4, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.78-5 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-06-11. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jun 4, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@shubham1206agra] The PR that introduced the bug has been identified. Link to the PR:
  • [@shubham1206agra] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
  • [@shubham1206agra] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
  • [@shubham1206agra] Determine if we should create a regression test for this bug.
  • [@shubham1206agra] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 10, 2024
Copy link

melvin-bot bot commented Jun 11, 2024

Issue is ready for payment but no BZ is assigned. @lschurr you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

Copy link

melvin-bot bot commented Jun 11, 2024

Payment Summary

Upwork Job

BugZero Checklist (@lschurr)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/jobs/~01eb357df404f2d36d)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

@lschurr
Copy link
Contributor

lschurr commented Jun 11, 2024

@shubham1206agra @tienifr - please accept the offers sent today so that we can pay and close :)

@tienifr
Copy link
Contributor

tienifr commented Jun 12, 2024

Thanks @lschurr, I accepted it

@shubham1206agra
Copy link
Contributor

@lschurr Accepted

@lschurr
Copy link
Contributor

lschurr commented Jun 12, 2024

All set!

@lschurr lschurr closed this as completed Jun 12, 2024
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 Engineering External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests