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 2023-12-28] [$500] IOU - Edit request option is present for paid message and error shows up when editing paid IOU #30448

Closed
6 tasks done
lanitochka17 opened this issue Oct 26, 2023 · 50 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Internal Requires API changes or must be handled by Expensify staff Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 26, 2023

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.3.91-6
Reproducible in staging?: Yes
Reproducible in production?: Yes
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:

Issue found when executing PR #29934

Action Performed:

  1. Go to staging.new.expensify.com
  2. Request money from a workspace chat
  3. Click on the expense preview to open expense report
  4. Click Pay elsewhere
  5. Hover over the system message for paid request
  6. Click Edit request
  7. Return to IOU report
  8. Hover over IOU preview and click Edit request
  9. Edit any field

Expected Result:

  • "Edit request" option should not be available for the system message for paid request
  • When clicking on "Edit request" on IOU preview, user should be able to edit the IOU details

Actual Result:

"Edit request" option is available for the system message for paid request. Clicking on it does not allow user to edit the request

  • When clicking on "Edit request" on IOU preview and user edits IOU details, error shows up

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

Bug6251899_1698331109368.Recording__296.1.mp4
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01a4085c4ba07d24d8
  • Upwork Job ID: 1727671655146373120
  • Last Price Increase: 2023-11-23
@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 Oct 26, 2023
@melvin-bot melvin-bot bot changed the title IOU - Edit request option is present for paid message and error shows up when editing paid IOU [$500] IOU - Edit request option is present for paid message and error shows up when editing paid IOU Oct 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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 Oct 26, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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

@melvin-bot
Copy link

melvin-bot bot commented Oct 26, 2023

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

@hungvu193
Copy link
Contributor

hungvu193 commented Oct 26, 2023

Proposal

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

IOU - Edit request option is present for paid message and error shows up when editing paid IOU

What is the root cause of that problem?

We're showing edit option for even the system message:

shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport) =>
type === CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) && !isArchivedRoom && !isChronosReport,

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

I think we shouldn't show the edit option for system message like that, so we need to update the condition here to:

const isSystemMessage = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && reportAction.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY;

return type === CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) && !isArchivedRoom && !isChronosReport && !isSystemMessage;

or we just need to bring this logic into canEditReportAction for cleaner logic.

What alternative solutions did you explore? (Optional)

N/A

@dukenv0307
Copy link
Contributor

dukenv0307 commented Oct 26, 2023

Proposal

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

Edit request option is present for paid message and error shows up when editing paid IOU

What is the root cause of that problem?

The edit option is shown based on canEditReportAction

type === CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canEditReportAction(reportAction) && !isArchivedRoom && !isChronosReport,

Let's see the condition in canEditReportAction

App/src/libs/ReportUtils.js

Lines 1620 to 1627 in 8c76d2a

return (
reportAction.actorAccountID === currentUserAccountID &&
isCommentOrIOU &&
canEditMoneyRequest(reportAction) && // Returns true for non-IOU actions
!isReportMessageAttachment(lodashGet(reportAction, ['message', 0], {})) &&
!ReportActionsUtils.isDeletedAction(reportAction) &&
!ReportActionsUtils.isCreatedTaskReportAction(reportAction) &&
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE

We have the check canEditMoneyRequest that will return true if the moneyRequestReport is expense report and the user is the admin. So the paid message has edit message option

App/src/libs/ReportUtils.js

Lines 1572 to 1574 in 8c76d2a

if (isAdmin) {
return true;
}

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

I think we shouldn't show the edit option for iou action. We show the edit option for MoneyRequestAction and when we click on it we will navigate to child report. It is the same behavior when we click on reply in thread so I think we only need to show reply in thread option for this case.

We should remove the check canEditMoneyRequest in canEditReportAction function and update isCommentOrIOU to isComment

const isComment = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT
return (
    reportAction.actorAccountID === currentUserAccountID &&
    isComment &&
    !isReportMessageAttachment(lodashGet(reportAction, ['message', 0], {})) &&
    !ReportActionsUtils.isDeletedAction(reportAction) &&
    !ReportActionsUtils.isCreatedTaskReportAction(reportAction) &&
    reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE
);

App/src/libs/ReportUtils.js

Lines 1620 to 1627 in 8c76d2a

return (
reportAction.actorAccountID === currentUserAccountID &&
isCommentOrIOU &&
canEditMoneyRequest(reportAction) && // Returns true for non-IOU actions
!isReportMessageAttachment(lodashGet(reportAction, ['message', 0], {})) &&
!ReportActionsUtils.isDeletedAction(reportAction) &&
!ReportActionsUtils.isCreatedTaskReportAction(reportAction) &&
reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE

And remove the logic for the money request action case here

if (ReportActionsUtils.isMoneyRequestAction(reportAction)) {

What alternative solutions did you explore? (Optional)

We can update canEditMoneyRequest to return false if the originalMessage type of the iou action is pay.

@Krishna2323
Copy link
Contributor

Krishna2323 commented Oct 26, 2023

Proposal

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

Edit request option is present for paid message and error shows up when editing paid IOU

What is the root cause of that problem?

We return true from canEditMoneyRequest function when user is admin.

App/src/libs/ReportUtils.js

Lines 1567 to 1574 in 8c76d2a

const moneyRequestReport = getReport(moneyRequestReportID);
const isReportSettled = isSettled(moneyRequestReport.reportID);
const isAdmin = isExpenseReport(moneyRequestReport) && lodashGet(getPolicy(moneyRequestReport.policyID), 'role', '') === CONST.POLICY.ROLE.ADMIN;
const isRequestor = currentUserAccountID === reportAction.actorAccountID;
if (isAdmin) {
return true;
}

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

I don't think we should return true in any case if payments is settled, so we should only return true when user is admin and payment is not settled.

Option 1

    if (isAdmin && !isReportSettled) {
        return true;
    }

Option 2
Or we can remove isAdmin check and modify the last return statement like this:

    return !isReportSettled && (isRequestor || isAdmin);

Option 3
We can also check if the request action type is IOU and is settled using isSettled function like we do in canEditMoneyRequest function.

@tienifr
Copy link
Contributor

tienifr commented Oct 27, 2023

Proposal

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

"Edit request" option is available for the system message for paid request. Clicking on it does not allow user to edit the request

When clicking on "Edit request" on IOU preview and user edits IOU details, error shows up

This one is currently not reproducible.

What is the root cause of that problem?

In here, we're not validating if the IOU report action is a 'CREATE' IOU report action.

IOU report action has many sub-types, create, pay, split, decline, ... Only the create type should be allowed to edit since it's the one that creates the money request. Other ones like pay, decline, ... are follow-up actions on that IOU and we should not allow editing the money request from these types.

Without that additional check, in this issue, since the pay request is also an IOU, it still shows the Edit request.

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

We need to update this with an additional check after this one: If the sub-type of the report action is not create, then early return.

if (reportAction.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.CREATE) {
    return false;
}

This will make sure everywhere we use canEditMoneyRequest, like in the ContextMenu case here, it will always return false for non-create report actions. And this will work for all sub-types of IOU, not just pay in this case.

What alternative solutions did you explore? (Optional)

NA

@mananjadhav
Copy link
Collaborator

Will test this and review this by tomorrow.

@melvin-bot melvin-bot bot added the Overdue label Oct 30, 2023
@garrettmknight
Copy link
Contributor

@mananjadhav did you get a chance to test/review?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 30, 2023
Copy link

melvin-bot bot commented Nov 2, 2023

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

@garrettmknight
Copy link
Contributor

@mananjadhav can you give this one a look when you get a chance?

@melvin-bot melvin-bot bot removed the Overdue label Nov 2, 2023
@mananjadhav
Copy link
Collaborator

mananjadhav commented Nov 3, 2023

I was stuck with low internet. I'll finish this by tomorrow.

@melvin-bot melvin-bot bot added the Overdue label Nov 6, 2023
Copy link

melvin-bot bot commented Nov 6, 2023

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

@garrettmknight
Copy link
Contributor

@mananjadhav can you prioritize this one this week?

@melvin-bot melvin-bot bot removed the Overdue label Nov 6, 2023
@mananjadhav
Copy link
Collaborator

@garrettmknight I was out sick, I'll have this prioritized today/tomorrow.

Copy link

melvin-bot bot commented Nov 9, 2023

@garrettmknight @mananjadhav 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!

@tienifr
Copy link
Contributor

tienifr commented Dec 5, 2023

@puneetlath Could we continue?

Copy link

melvin-bot bot commented Dec 5, 2023

@puneetlath, @garrettmknight, @mananjadhav Huh... This is 4 days overdue. Who can take care of this?

Copy link

melvin-bot bot commented Dec 6, 2023

@puneetlath, @garrettmknight, @mananjadhav Eep! 4 days overdue now. Issues have feelings too...

@puneetlath
Copy link
Contributor

Let's do it. Sorry for the delay!

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Dec 7, 2023
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Dec 21, 2023
@melvin-bot melvin-bot bot changed the title [$500] IOU - Edit request option is present for paid message and error shows up when editing paid IOU [HOLD for payment 2023-12-28] [$500] IOU - Edit request option is present for paid message and error shows up when editing paid IOU Dec 21, 2023
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Dec 21, 2023
Copy link

melvin-bot bot commented Dec 21, 2023

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Dec 21, 2023

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.14-6 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 2023-12-28. 🎊

After the hold period is over and BZ checklist items are completed, please complete any of the applicable payments for this issue, and check them off once done.

  • External issue reporter
  • Contributor that fixed the issue
  • Contributor+ that helped on the issue and/or PR

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

  • @mananjadhav requires payment through NewDot Manual Requests
  • @tienifr requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Dec 21, 2023

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:

  • [@mananjadhav] The PR that introduced the bug has been identified. Link to the PR:
  • [@mananjadhav] 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:
  • [@mananjadhav] 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:
  • [@mananjadhav] Determine if we should create a regression test for this bug.
  • [@mananjadhav] 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.
  • [@garrettmknight] 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 Dec 27, 2023
@garrettmknight
Copy link
Contributor

@mananjadhav
Copy link
Collaborator

I couldn't pinpoint to an exact PR for this one. Because we have canEditMoneyRequest since long. I also don't think we need a regression test for this one. @puneetlath @garrettmknight wdyt?

@garrettmknight Can you please post a payout summary for me to raise a request?

@garrettmknight
Copy link
Contributor

Summary of payments:

@garrettmknight garrettmknight added Weekly KSv2 and removed Daily KSv2 labels Dec 29, 2023
@garrettmknight
Copy link
Contributor

Dropping to weekly for payment

@JmillsExpensify
Copy link

$500 payment approved for @mananjadhav based on summary above.

@melvin-bot melvin-bot bot added the Overdue label Jan 8, 2024
@melvin-bot melvin-bot bot removed the Overdue label Jan 8, 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. Internal Requires API changes or must be handled by Expensify staff Weekly KSv2
Projects
None yet
Development

No branches or pull requests

9 participants