Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Expensify/App into aldo_fix-exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
aldo-expensify committed Sep 26, 2024
2 parents e7b82ab + a935a15 commit 270f24e
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2186,7 +2186,7 @@ const CONST = {
AUTO_REIMBURSEMENT_MAX_LIMIT_CENTS: 2000000,
AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENTS: 10000,
AUTO_APPROVE_REPORTS_UNDER_DEFAULT_CENTS: 10000,
RANDOM_AUDIT_DEFAULT_PERCENTAGE: 5,
RANDOM_AUDIT_DEFAULT_PERCENTAGE: 0.05,

AUTO_REPORTING_FREQUENCIES: {
INSTANT: 'instant',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import type {
DefaultVendorDescriptionParams,
DelegateRoleParams,
DelegateSubmitParams,
DelegatorParams,
DeleteActionParams,
DeleteConfirmationParams,
DeleteExpenseTranslationParams,
Expand Down Expand Up @@ -4818,7 +4819,7 @@ const translations = {
}
},
genericError: 'Oops, something went wrong. Please try again.',
onBehalfOfMessage: (delegator: string) => `on behalf of ${delegator}`,
onBehalfOfMessage: ({delegator}: DelegatorParams) => `on behalf of ${delegator}`,
accessLevel: 'Access level',
confirmCopilot: 'Confirm your copilot below.',
accessLevelDescription: 'Choose an access level below. Both Full and Limited access allow copilots to view all conversations and expenses.',
Expand Down
3 changes: 2 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import type {
DefaultVendorDescriptionParams,
DelegateRoleParams,
DelegateSubmitParams,
DelegatorParams,
DeleteActionParams,
DeleteConfirmationParams,
DeleteExpenseTranslationParams,
Expand Down Expand Up @@ -5338,7 +5339,7 @@ const translations = {
}
},
genericError: '¡Ups! Ha ocurrido un error. Por favor, inténtalo de nuevo.',
onBehalfOfMessage: (delegator: string) => `en nombre de ${delegator}`,
onBehalfOfMessage: ({delegator}: DelegatorParams) => `en nombre de ${delegator}`,
accessLevel: 'Nivel de acceso',
confirmCopilot: 'Confirma tu copiloto a continuación.',
accessLevelDescription: 'Elige un nivel de acceso a continuación. Tanto el acceso Completo como el Limitado permiten a los copilotos ver todas las conversaciones y gastos.',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ type ReconciliationWorksParams = {lastFourPAN: string};

type DelegateRoleParams = {role: DelegateRole};

type DelegatorParams = {delegator: string};

type RoleNamesParams = {role: string};

type AssignCardParams = {
Expand Down Expand Up @@ -565,6 +567,7 @@ export type {
AssignedYouCardParams,
SpreadCategoriesParams,
DelegateRoleParams,
DelegatorParams,
ReconciliationWorksParams,
LastSyncAccountingParams,
SyncStageNameConnectionsParams,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/API/parameters/SetPolicyAutoReimbursementLimit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type SetPolicyAutoReimbursementLimitParams = {
policyID: string;
autoReimbursement: {limit: number};
limit: number;
};

export default SetPolicyAutoReimbursementLimitParams;
37 changes: 11 additions & 26 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4160,9 +4160,10 @@ function setPolicyAutomaticApprovalLimit(policyID: string, limit: string) {
function setPolicyAutomaticApprovalRate(policyID: string, auditRate: string) {
const policy = getPolicy(policyID);
const fallbackAuditRate = auditRate === '' ? '0' : auditRate;
const parsedAuditRate = parseInt(fallbackAuditRate, 10);
const parsedAuditRate = parseInt(fallbackAuditRate, 10) / 100;

if (parsedAuditRate === policy?.autoApproval?.auditRate ?? CONST.POLICY.RANDOM_AUDIT_DEFAULT_PERCENTAGE) {
// The auditRate arrives as an int to this method so we will convert it to a float before sending it to the API.
if (parsedAuditRate === (policy?.autoApproval?.auditRate ?? CONST.POLICY.RANDOM_AUDIT_DEFAULT_PERCENTAGE)) {
return;
}

Expand Down Expand Up @@ -4238,17 +4239,8 @@ function enableAutoApprovalOptions(policyID: string, enabled: boolean) {
return;
}

const autoApprovalCleanupValues = !enabled
? {
pendingFields: {
limit: null,
auditRate: null,
},
}
: {};
const autoApprovalValues = !enabled ? {auditRate: CONST.POLICY.RANDOM_AUDIT_DEFAULT_PERCENTAGE, limit: CONST.POLICY.AUTO_APPROVE_REPORTS_UNDER_DEFAULT_CENTS} : {};
const autoApprovalFailureValues = !enabled ? {autoApproval: {limit: policy?.autoApproval?.limit, auditRate: policy?.autoApproval?.auditRate, ...autoApprovalCleanupValues}} : {};

const autoApprovalValues = {auditRate: CONST.POLICY.RANDOM_AUDIT_DEFAULT_PERCENTAGE, limit: CONST.POLICY.AUTO_APPROVE_REPORTS_UNDER_DEFAULT_CENTS};
const autoApprovalFailureValues = {autoApproval: {limit: policy?.autoApproval?.limit, auditRate: policy?.autoApproval?.auditRate, pendingFields: null}};
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -4274,7 +4266,7 @@ function enableAutoApprovalOptions(policyID: string, enabled: boolean) {
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
autoApproval: {...autoApprovalCleanupValues},
autoApproval: {pendingFields: null},
pendingFields: {
shouldShowAutoApprovalOptions: null,
},
Expand Down Expand Up @@ -4367,7 +4359,7 @@ function setPolicyAutoReimbursementLimit(policyID: string, limit: string) {
];

const parameters: SetPolicyAutoReimbursementLimitParams = {
autoReimbursement: {limit: parsedLimit},
limit: parsedLimit,
policyID,
};

Expand All @@ -4380,6 +4372,7 @@ function setPolicyAutoReimbursementLimit(policyID: string, limit: string) {

/**
* Call the API to enable auto-payment for the reports in the given policy
*
* @param policyID - id of the policy to apply the limit to
* @param enabled - whether auto-payment for the reports is enabled in the given policy
*/
Expand All @@ -4390,16 +4383,8 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean)
return;
}

const autoReimbursementCleanupValues = !enabled
? {
pendingFields: {
limit: null,
},
}
: {};
const autoReimbursementFailureValues = !enabled ? {autoReimbursement: {limit: policy?.autoReimbursement?.limit, ...autoReimbursementCleanupValues}} : {};
const autoReimbursementValues = !enabled ? {limit: CONST.POLICY.AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENTS} : {};

const autoReimbursementFailureValues = {autoReimbursement: {limit: policy?.autoReimbursement?.limit, pendingFields: null}};
const autoReimbursementValues = {limit: CONST.POLICY.AUTO_REIMBURSEMENT_DEFAULT_LIMIT_CENTS};
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -4424,7 +4409,7 @@ function enablePolicyAutoReimbursementLimit(policyID: string, enabled: boolean)
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
autoReimbursement: {...autoReimbursementCleanupValues},
autoReimbursement: {pendingFields: null},
pendingFields: {
shouldShowAutoReimbursementLimitOption: null,
},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ function ReportActionItemSingle({
</View>
) : null}
{action?.delegateAccountID && !isReportPreviewAction && (
<Text style={[styles.chatDelegateMessage]}>{translate('delegate.onBehalfOfMessage', accountOwnerDetails?.displayName ?? '')}</Text>
<Text style={[styles.chatDelegateMessage]}>{translate('delegate.onBehalfOfMessage', {delegator: accountOwnerDetails?.displayName ?? ''})}</Text>
)}
<View style={hasBeenFlagged ? styles.blockquote : {}}>{children}</View>
</View>
Expand Down
15 changes: 4 additions & 11 deletions src/pages/workspace/rules/ExpenseReportRulesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function ExpenseReportRulesSection({policyID}: ExpenseReportRulesSectionProps) {
);
};

const reportTitlePendingFields = policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE]?.pendingFields ?? {};
const optionItems = [
{
title: translate('workspace.rules.expenseReportRules.customReportNamesTitle'),
Expand All @@ -62,11 +63,7 @@ function ExpenseReportRulesSection({policyID}: ExpenseReportRulesSectionProps) {
onToggle: (isEnabled: boolean) => PolicyActions.enablePolicyDefaultReportTitle(policyID, isEnabled),
subMenuItems: [
<OfflineWithFeedback
pendingAction={
!policy?.pendingFields?.shouldShowCustomReportTitleOption && policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE].pendingFields?.defaultValue
? policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE].pendingFields?.defaultValue
: null
}
pendingAction={!policy?.pendingFields?.shouldShowCustomReportTitleOption && reportTitlePendingFields.defaultValue ? reportTitlePendingFields.defaultValue : null}
key="customName"
>
<MenuItemWithTopDescription
Expand All @@ -78,11 +75,7 @@ function ExpenseReportRulesSection({policyID}: ExpenseReportRulesSectionProps) {
/>
</OfflineWithFeedback>,
<ToggleSettingOptionRow
pendingAction={
!policy?.pendingFields?.shouldShowCustomReportTitleOption && policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE].pendingFields?.deletable
? policy?.fieldList?.[CONST.POLICY.FIELDS.FIELD_LIST_TITLE].pendingFields?.deletable
: null
}
pendingAction={!policy?.pendingFields?.shouldShowCustomReportTitleOption && reportTitlePendingFields.deletable ? reportTitlePendingFields.deletable : null}
key="preventMembersFromChangingCustomNames"
title={translate('workspace.rules.expenseReportRules.preventMembersFromChangingCustomNamesTitle')}
switchAccessibilityLabel={translate('workspace.rules.expenseReportRules.preventMembersFromChangingCustomNamesTitle')}
Expand Down Expand Up @@ -142,7 +135,7 @@ function ExpenseReportRulesSection({policyID}: ExpenseReportRulesSectionProps) {
>
<MenuItemWithTopDescription
description={translate('workspace.rules.expenseReportRules.randomReportAuditTitle')}
title={`${policy?.autoApproval?.auditRate ?? CONST.POLICY.RANDOM_AUDIT_DEFAULT_PERCENTAGE}%`}
title={`${Math.round((policy?.autoApproval?.auditRate ?? CONST.POLICY.RANDOM_AUDIT_DEFAULT_PERCENTAGE) * 100)}%`}
shouldShowRightIcon
style={[styles.sectionMenuItemTopDescription, styles.mt6, styles.mbn3]}
onPress={() => Navigation.navigate(ROUTES.RULES_RANDOM_REPORT_AUDIT.getRoute(policyID))}
Expand Down
3 changes: 1 addition & 2 deletions src/pages/workspace/rules/RulesRandomReportAuditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ function RulesRandomReportAuditPage({route}: RulesRandomReportAuditPageProps) {
const styles = useThemeStyles();

const workflowApprovalsUnavailable = PolicyUtils.getWorkflowApprovalsUnavailable(policy);
const defaultValue = policy?.autoApproval?.auditRate ?? CONST.POLICY.RANDOM_AUDIT_DEFAULT_PERCENTAGE;

const defaultValue = Math.round((policy?.autoApproval?.auditRate ?? CONST.POLICY.RANDOM_AUDIT_DEFAULT_PERCENTAGE) * 100);
return (
<AccessOrNotFoundWrapper
policyID={policyID}
Expand Down

0 comments on commit 270f24e

Please sign in to comment.