Skip to content

[$250] Expense - Submit expense option is not disabled for users who are invited to expense report #46340

Closed

Description

@lanitochka17

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: 9.0.13-3
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/4771930
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. [User A] Submit two expenses to User B
  3. [User A] Click on the expense preview in the main chat to go to expense report
  4. [User A] Send a user mention containing User C
  5. [User A] Click Invite from the whisper message
  6. [User A] Send a message in the transaction thread
  7. [User C] Open the invited expense report
  8. [User C] Click + > Submit expense > Manual
  9. [User C] Enter amount > Next

Expected Result:

Submit expense option should be disabled for the users who are invited to the expense rep

Actual Result:

Submit expense option is not disabled for the users who are invited to the expense report
Invited user can go through the flow but blocked at the confirmation page

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

Bug6553848_1722011341978.20240727_002330.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01966947a9e891013b
  • Upwork Job ID: 1821180390230444112
  • Last Price Increase: 2024-08-07
  • Automatic offers:
    • dukenv0307 | Reviewer | 103502917
    • nkdengineer | Contributor | 103502920
Issue OwnerCurrent Issue Owner: @zanyrenney

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 27, 2024
  2. melvin-bot commented on Jul 27, 2024

    @melvin-bot

    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.

  3. lanitochka17 commented on Jul 27, 2024

    @lanitochka17
    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

  4. lanitochka17 commented on Jul 27, 2024

    @lanitochka17
    Author

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

  5. nkdengineer commented on Jul 27, 2024

    @nkdengineer
    Contributor

    Edited by proposal-police: This proposal was edited at 2023-10-21T22:06:00Z.

    Proposal

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

    Submit expense option is not disabled for the users who are invited to the expense report
    Invited user can go through the flow but blocked at the confirmation page

    What is the root cause of that problem?

    For the iou report, the policy is the personal policy of the user so canAddOrDeleteTransactions always returns true without checking whether the user can access the parent report or not.

    App/src/libs/ReportUtils.ts

    Lines 1604 to 1608 in 5e65276

    function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): boolean {
    if (!isMoneyRequestReport(moneyRequestReport)) {
    return false;
    }

    When we submit an expense, we get the participants from the chat report and in this case, the invited user can't access this report so participants is an empty object, and then the confirm button is disabled on the confirmation page

    const chatReportOtherParticipants = Object.keys(chatReport?.participants ?? {})

    For the expense report, the invited user doesn't have the policy data of the expense report, and canAddTransactions also returns true in this case then the invited user can see the submit expense option in the expense report

    return isReportInGroupPolicy(report) ? isOwnPolicyExpenseChat && canAddTransactions : canAddTransactions;

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

    We should check if the user can not access the parent report we will return false

    if (!isMoneyRequestReport(moneyRequestReport) || !getParentReport(moneyRequestReport)?.reportID) {
        return false;
    }
    

    App/src/libs/ReportUtils.ts

    Lines 1604 to 1608 in 5e65276

    function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): boolean {
    if (!isMoneyRequestReport(moneyRequestReport)) {
    return false;
    }

    What alternative solutions did you explore? (Optional)

    Or we can check for iou report that will return false if the current user is not the manager and is not the owner of the iou report

    if (isIOUReport(moneyRequestReport) && currentUserAccountID !== moneyRequestReport?.managerID && currentUserAccountID !== moneyRequestReport?.ownerAccountID) {
        return false;
    }
    

    App/src/libs/ReportUtils.ts

    Lines 1604 to 1608 in 5e65276

    function canAddOrDeleteTransactions(moneyRequestReport: OnyxEntry<Report>): boolean {
    if (!isMoneyRequestReport(moneyRequestReport)) {
    return false;
    }

    For the expense report, we can add the check isExpenseReport here

    return (isReportInGroupPolicy(report) || isExpenseReport(report)) ? isOwnPolicyExpenseChat && canAddTransactions : canAddTransactions; 
    
    

    return isReportInGroupPolicy(report) ? isOwnPolicyExpenseChat && canAddTransactions : canAddTransactions;

    if (isExpenseReport(moneyRequestReport) && currentUserAccountID !== moneyRequestReport?.managerID) {
        return false;
    }
    

    or we can add a case in canAddOrDeleteTransactions for the expense report that will return false if the current user isn't the managerID (the submitter) of the expense report

  6. OfstadC commented on Jul 30, 2024

    @OfstadC
    Contributor

    Assigned to me while I was OoO - reassigning

  7. removed
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 30, 2024
  8. removed their assignment
    on Jul 30, 2024
  9. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 30, 2024
  10. melvin-bot commented on Jul 30, 2024

    @melvin-bot

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

  11. 41 remaining items

  12. melvin-bot commented on Sep 12, 2024

    @melvin-bot

    This issue has not been updated in over 15 days. @zanyrenney, @aldo-expensify, @dukenv0307, @nkdengineer 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!

  13. nkdengineer commented on Sep 30, 2024

    @nkdengineer
    Contributor

    @zanyrenney The Issue was deployed to production 1 month ago. Should we process payment here

  14. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed
    ReviewingHas a PR in review
    on Oct 1, 2024
  15. aldo-expensify commented on Oct 1, 2024

    @aldo-expensify
    Contributor

    The payment summary would be:

    @dukenv0307 in C+ role: $250
    @nkdengineer in contributor role: $250

    Correct?

  16. dukenv0307 commented on Oct 2, 2024

    @dukenv0307
    Contributor
  17. nkdengineer commented on Oct 2, 2024

    @nkdengineer
    Contributor
  18. zanyrenney commented on Oct 4, 2024

    @zanyrenney
    Contributor

    payment summary

    @dukenv0307 in C+ role: $250 paid via upwork
    @nkdengineer in contributor role: $250 paid via upwork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions