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

Allow selfApproval when the rule feature is disabled #55386

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8242,6 +8242,9 @@ function isReportOwner(report: OnyxInputOrEntry<Report>): boolean {

function isAllowedToApproveExpenseReport(report: OnyxEntry<Report>, approverAccountID?: number, reportPolicy?: OnyxEntry<Policy> | SearchPolicy): boolean {
const policy = reportPolicy ?? getPolicy(report?.policyID);
if (!policy?.areRulesEnabled) {
return true;
}
Comment on lines +8245 to +8247
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made some backend changes where this will not be needed, actually this could lead to some older reports that never enabled or disabled the feature to skip this call because the default is false but they could have set the prevent self approval to true in OldDot

Suggested change
if (!policy?.areRulesEnabled) {
return true;
}
if (!policy?.areRulesEnabled) {
return true;
}

Copy link
Contributor

@hungvu193 hungvu193 Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, if we do that, doesn't that we should select TonyMK proposal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we could have, we can give TonyMK partial reward for their proposal

const isOwner = (approverAccountID ?? currentUserAccountID) === report?.ownerAccountID;
return !(policy?.preventSelfApproval && isOwner);
}
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ type SearchPolicy = {
/** Whether the auto reporting is enabled */
autoReporting?: boolean;

/** Whether the rules feature is enabled */
areRulesEnabled?: boolean;

/**
* The scheduled submit frequency set up on this policy.
* Note that manual does not exist in the DB and thus should not exist in Onyx, only as a param for the API.
Expand Down
Loading