-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
pay conditions based on reimbursement settings #36814
Changes from 10 commits
8efc85b
7b5b8ac
1c9b2a2
6cd13a0
0bce44c
4f8a178
805b511
c142581
eec5698
e616fe7
760e51b
f0b7d00
e9306bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import type {ValueOf} from 'type-fest'; | |
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
import type {PersonalDetailsList, Policy, PolicyMembers, PolicyTagList, PolicyTags} from '@src/types/onyx'; | ||
import type {PersonalDetailsList, Policy, PolicyMembers, PolicyTagList, PolicyTags, Session} from '@src/types/onyx'; | ||
import type {EmptyObject} from '@src/types/utils/EmptyObject'; | ||
import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
import Navigation from './Navigation/Navigation'; | ||
|
@@ -117,6 +117,16 @@ const isFreeGroupPolicy = (policy: OnyxEntry<Policy> | EmptyObject): boolean => | |
|
||
const isPolicyMember = (policyID: string, policies: OnyxCollection<Policy>): boolean => Object.values(policies ?? {}).some((policy) => policy?.id === policyID); | ||
|
||
const isPolicyPayer = (policy: OnyxEntry<Policy> | EmptyObject, session: OnyxEntry<Session>, isApproved: boolean, isManager: boolean, isAdmin: boolean): boolean => { | ||
if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES) { | ||
const isReimburser = session?.email === policy?.reimburserEmail; | ||
return isReimburser && (isApproved || isManager); | ||
} | ||
if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) { | ||
return isAdmin && (isApproved || isManager); | ||
} | ||
return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to show the Pay button for IOUs (and free workspaces for now), I think we need to check if the user is manager and if the policy is not a group policy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! Focused too much only on policies and let this blunder slide. Fixed now. One last question, we show only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh good question, we should show both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Done. 👍 |
||
}; | ||
/** | ||
* Create an object mapping member emails to their accountIDs. Filter for members without errors, and get the login email from the personalDetail object using the accountID. | ||
* | ||
|
@@ -284,6 +294,7 @@ export { | |
getCountOfEnabledTagsOfList, | ||
isPendingDeletePolicy, | ||
isPolicyMember, | ||
isPolicyPayer, | ||
isPaidGroupPolicy, | ||
extractPolicyIDFromPath, | ||
getPathWithoutPolicyID, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change the name to
isPayer
since it would be used for IOUs too to avoid a regression