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 #52345][$250] Scan - "Delete" and "Replace" options are displayed for an admin which causes an error #50113

Open
4 of 6 tasks
lanitochka17 opened this issue Oct 2, 2024 · 41 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 2, 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.43-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/5035807
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Action Performed:

Prerequisite
Create a workspace and invite an employee to the workspace
Login as an owner and employee

  1. As the employee navigate to the workspace chat and click on the + icon > Submit expense > Scan
  2. Upload a receipt and finish the flow
  3. After the expense is created navigate to the tab where you are logged in as the admin/owner
  4. Click on the receipt thumbnail
  5. Here notice that the "Delete" and "Replace" options are displayed
  6. Click on "Replace" > Choose another receipt or take a photo of it > Upload
  7. Click on "Delete" > Confirm > Notice that an error is thrown

Expected Result:

The workspace admin cannot edit the receipt file so there should not be "Delete" and "Replace" options

Actual Result:

The ‘Delete’ and ‘Replace’ options are displayed, but when ‘Delete’ is executed, an error occurs and when ‘Replace’ is executed, the receipt is replaced

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

Add any screenshot/video evidence

Bug6622555_1727899943377.RPReplay_Final1727899518.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021843656533685450338
  • Upwork Job ID: 1843656533685450338
  • Last Price Increase: 2024-11-05
Issue OwnerCurrent Issue Owner: @OfstadC
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

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

@lanitochka17
Copy link
Author

@OfstadC FYI 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

@lanitochka17
Copy link
Author

We think that this bug might be related to #wave-collect - Release 1

@Krishna2323
Copy link
Contributor

Krishna2323 commented Oct 2, 2024

Edited by proposal-police: This proposal was edited at 2024-10-02 20:36:01 UTC.

Proposal


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

Scan - "Delete" and "Replace" options are displayed for an admin which causes an error

What is the root cause of that problem?

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


  • We should update it to readonly={readonly || !canEditReceipt}.
  • We also need to remove the isAdmin || isManager || part from the condition below, if we want, we can keep isManager.

    App/src/libs/ReportUtils.ts

    Lines 3098 to 3106 in 19a137d

    if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.RECEIPT) {
    const isRequestor = currentUserAccountID === reportAction?.actorAccountID;
    return (
    !isInvoiceReport(moneyRequestReport) &&
    !TransactionUtils.isReceiptBeingScanned(transaction) &&
    !TransactionUtils.isDistanceRequest(transaction) &&
    (isAdmin || isManager || isRequestor)
    );
    }

What alternative solutions did you explore? (Optional)

Result

@daledah
Copy link
Contributor

daledah commented Oct 2, 2024

Proposal

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

The ‘Delete’ and ‘Replace’ options are displayed, but when ‘Delete’ is executed, an error occurs and when ‘Replace’ is executed, the receipt is replaced

What is the root cause of that problem?

In ReportUtils.canEditFieldOfMoneyRequest:

App/src/libs/ReportUtils.ts

Lines 3098 to 3106 in 7992d21

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.RECEIPT) {
const isRequestor = currentUserAccountID === reportAction?.actorAccountID;
return (
!isInvoiceReport(moneyRequestReport) &&
!TransactionUtils.isReceiptBeingScanned(transaction) &&
!TransactionUtils.isDistanceRequest(transaction) &&
(isAdmin || isManager || isRequestor)
);
}

If user is admin or manager, this function returns true, so admins can edit receipt.

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

Remove isAdmin and isManager from this condition:

App/src/libs/ReportUtils.ts

Lines 3098 to 3106 in 7992d21

if (fieldToEdit === CONST.EDIT_REQUEST_FIELD.RECEIPT) {
const isRequestor = currentUserAccountID === reportAction?.actorAccountID;
return (
!isInvoiceReport(moneyRequestReport) &&
!TransactionUtils.isReceiptBeingScanned(transaction) &&
!TransactionUtils.isDistanceRequest(transaction) &&
(isAdmin || isManager || isRequestor)
);
}

What alternative solutions did you explore? (Optional)

NA

@abzokhattab
Copy link
Contributor

Dupe of #47242

@Nodebrute
Copy link
Contributor

Nodebrute commented Oct 3, 2024

Moving my proposal from here #47242 (comment)

Proposal

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

"Delete" and "Replace" options are displayed for an admin which causes an error

What is the root cause of that problem?

We are allowing Admin to edit receipt here

(isAdmin || isManager || isRequestor)

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

We can remove isAdmin from here

(isAdmin || isManager || isRequestor)

What alternative solutions did you explore? (Optional)

In case we only want to allow requestor to delete and replace the reciept than we can remove both options isAdmin and isManager

@melvin-bot melvin-bot bot added the Overdue label Oct 7, 2024
@OfstadC OfstadC added the External Added to denote the issue can be worked on by a contributor label Oct 8, 2024
Copy link

melvin-bot bot commented Oct 8, 2024

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

@melvin-bot melvin-bot bot changed the title Scan - "Delete" and "Replace" options are displayed for an admin which causes an error [$250] Scan - "Delete" and "Replace" options are displayed for an admin which causes an error Oct 8, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 8, 2024
Copy link

melvin-bot bot commented Oct 8, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Oct 8, 2024
@Ollyws
Copy link
Contributor

Ollyws commented Oct 10, 2024

Is this still reproducible for everyone else? I'm only getting the download option as admin/owner:

Screenshot 2024-10-10 at 10 06 01

Copy link

melvin-bot bot commented Oct 15, 2024

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

@melvin-bot melvin-bot bot added the Overdue label Oct 15, 2024
Copy link

melvin-bot bot commented Oct 15, 2024

@Ollyws, @OfstadC Eep! 4 days overdue now. Issues have feelings too...

Copy link

melvin-bot bot commented Oct 16, 2024

@Ollyws @OfstadC 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!

@Ollyws
Copy link
Contributor

Ollyws commented Oct 17, 2024

@Nodebrute @abzokhattab @daledah are you still able to reproduce?

@melvin-bot melvin-bot bot removed the Overdue label Oct 17, 2024
@daledah
Copy link
Contributor

daledah commented Oct 17, 2024

@Ollyws I can no longer reproduce the bug.

Screen.Recording.2024-10-17.at.17.17.18.mov

@OfstadC OfstadC added the Needs Reproduction Reproducible steps needed label Oct 17, 2024
@melvin-bot melvin-bot bot added the Overdue label Nov 1, 2024
Copy link

melvin-bot bot commented Nov 4, 2024

@Ollyws, @OfstadC Huh... This is 4 days overdue. Who can take care of this?

@OfstadC
Copy link
Contributor

OfstadC commented Nov 4, 2024

Friendly bump @Ollyws 😃

@melvin-bot melvin-bot bot removed the Overdue label Nov 4, 2024
Copy link

melvin-bot bot commented Nov 5, 2024

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

@Ollyws
Copy link
Contributor

Ollyws commented Nov 5, 2024

Apologies for the delay, looking into this...

@Ollyws
Copy link
Contributor

Ollyws commented Nov 7, 2024

I think as @Nodebrute did post their proposal first in the dupe issue #47242 (comment) it's fair that we go with that.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Nov 7, 2024

Triggered auto assignment to @tgolen, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@tgolen
Copy link
Contributor

tgolen commented Nov 7, 2024

I think those actions are there intentionally, and that the idea was always that an admin should be able to do those things. So, if there is an error happening, I think we should dig into those errors and fix them, rather than removing the functionality.

@JmillsExpensify does this ring a bell for you and am I remembering this correctly?

@tgolen
Copy link
Contributor

tgolen commented Nov 8, 2024

@lanitochka17 I confirmed that the frontend functionality is correct. Can you please update this issue to only focus on fixing the errors that happen? If this needs to be handled internally, that's fine, but I'd like to get some more information for this such as the logs for the delete/replace requests that have the errors.

@OfstadC If you're able to reproduce this, could you please try to get the requestID for me following this SO?

@tgolen
Copy link
Contributor

tgolen commented Nov 11, 2024

Bump @lanitochka17 @OfstadC

@melvin-bot melvin-bot bot added the Overdue label Nov 11, 2024
@OfstadC
Copy link
Contributor

OfstadC commented Nov 11, 2024

Sorry @tgolen ! Was OoO - looking now 😃

@OfstadC
Copy link
Contributor

OfstadC commented Nov 11, 2024

@tgolen I was able to reproduce today

jsonCode
:
405
message
:
"405 Cannot detach receipt from unowned transaction"
onyxData
:
[]
requestID
:
"8e109b54d92daccc-MSP"

@tgolen
Copy link
Contributor

tgolen commented Nov 11, 2024

Awesome! Here are the logs for that request.

It looks like that error is a very old error (at least 7 years old). So, it looks like in order for us to allow that operation, we need to make an update to Auth.

Can you please go here and open up a new issue using the "Open an internal issue for a backend fix" template with all the relevant info? Then it will get assigned to an engineer to fix.

@OfstadC
Copy link
Contributor

OfstadC commented Nov 11, 2024

Done! Thanks @tgolen for your help!

@OfstadC OfstadC changed the title [$250] Scan - "Delete" and "Replace" options are displayed for an admin which causes an error [HOLD for #52345][$250] Scan - "Delete" and "Replace" options are displayed for an admin which causes an error Nov 11, 2024
Copy link

melvin-bot bot commented Nov 12, 2024

@tgolen, @Ollyws, @OfstadC Eep! 4 days overdue now. Issues have feelings too...

@OfstadC OfstadC added Weekly KSv2 and removed Daily KSv2 labels Nov 12, 2024
@melvin-bot melvin-bot bot removed the Overdue label Nov 12, 2024
@OfstadC OfstadC removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 12, 2024
@OfstadC
Copy link
Contributor

OfstadC commented Nov 18, 2024

Discussion in linked GH

@OfstadC
Copy link
Contributor

OfstadC commented Nov 25, 2024

Jules is assigned to E/E issue 😃

@OfstadC OfstadC added Monthly KSv2 and removed Weekly KSv2 labels Dec 2, 2024
@garrettmknight garrettmknight moved this to Bugs and Follow Up Issues in [#whatsnext] #expense Dec 10, 2024
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. External Added to denote the issue can be worked on by a contributor Monthly KSv2
Projects
Status: Bugs and Follow Up Issues
Development

No branches or pull requests

10 participants