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

Fix editing Approver offline and description for Individual expense in "Flags amount over" #49049

Merged
Merged
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
36 changes: 22 additions & 14 deletions src/libs/actions/Policy/Category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1180,8 +1180,10 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro
value: {
rules: {
approvalRules: updatedApprovalRules,
pendingFields: {
approvalRules: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
pendingRulesUpdates: {
[categoryName]: {
approvalRule: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
Expand All @@ -1192,9 +1194,9 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
rules: {
pendingFields: {
approvalRules: null,
pendingRulesUpdates: {
[categoryName]: {
approvalRule: null,
},
},
},
Expand All @@ -1207,8 +1209,10 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro
value: {
rules: {
approvalRules,
pendingFields: {
approvalRules: null,
},
pendingRulesUpdates: {
[categoryName]: {
approvalRule: null,
},
},
},
Expand Down Expand Up @@ -1260,8 +1264,10 @@ function setPolicyCategoryTax(policyID: string, categoryName: string, taxID: str
value: {
rules: {
expenseRules: updatedExpenseRules,
pendingFields: {
expenseRules: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
pendingRulesUpdates: {
[categoryName]: {
expenseRule: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
},
},
},
Expand All @@ -1272,9 +1278,9 @@ function setPolicyCategoryTax(policyID: string, categoryName: string, taxID: str
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
value: {
rules: {
pendingFields: {
expenseRules: null,
pendingRulesUpdates: {
[categoryName]: {
expenseRule: null,
},
},
},
Expand All @@ -1287,8 +1293,10 @@ function setPolicyCategoryTax(policyID: string, categoryName: string, taxID: str
value: {
rules: {
expenseRules,
pendingFields: {
expenseRules: null,
},
pendingRulesUpdates: {
[categoryName]: {
expenseRule: null,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/categories/CategorySettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function CategorySettingsPage({
/>
</OfflineWithFeedback>
)}
<OfflineWithFeedback pendingAction={policy?.rules?.pendingFields?.approvalRules}>
<OfflineWithFeedback pendingAction={policy?.pendingRulesUpdates?.[categoryName]?.approvalRule}>
<MenuItemWithTopDescription
title={approverText}
description={translate('workspace.rules.categoryRules.approver')}
Expand All @@ -281,7 +281,7 @@ function CategorySettingsPage({
</Text>
)}
{policy?.tax?.trackingEnabled && (
<OfflineWithFeedback pendingAction={policy?.rules?.pendingFields?.expenseRules}>
<OfflineWithFeedback pendingAction={policy?.pendingRulesUpdates?.[categoryName]?.expenseRule}>
<MenuItemWithTopDescription
title={defaultTaxRateText}
description={translate('workspace.rules.categoryRules.defaultTaxRate')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ function ExpenseLimitTypeSelectorModal({isVisible, currentExpenseLimitType, onEx
shouldSingleExecuteRowSelect
containerStyle={[styles.pt3]}
initiallyFocusedOptionKey={currentExpenseLimitType}
isAlternateTextMultilineSupported
alternateTextNumberOfLines={3}
/>
</ScreenWrapper>
</Modal>
Expand Down
19 changes: 17 additions & 2 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,9 @@ type ExpenseRule = {
id?: string;
};

/** The name of the category or tag */
type CategoryOrTagName = string;

/** Model of policy data */
type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<
{
Expand Down Expand Up @@ -1586,13 +1589,13 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<
taxRates?: TaxRatesWithDefault;

/** A set of rules related to the workpsace */
rules?: OnyxCommon.OnyxValueWithOfflineFeedback<{
rules?: {
/** A set of rules related to the workpsace approvals */
approvalRules?: ApprovalRule[];

/** A set of rules related to the workpsace expenses */
expenseRules?: ExpenseRule[];
}>;
};

/** ReportID of the admins room for this workspace */
chatReportIDAdmins?: number;
Expand Down Expand Up @@ -1683,6 +1686,18 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<

/** Workspace account ID configured for Expensify Card */
workspaceAccountID?: number;

/** Information about rules being updated */
pendingRulesUpdates?: Record<
CategoryOrTagName,
{
/** Indicates whether the approval rule is updated for the given category or tag */
approvalRule: OnyxCommon.PendingAction;

/** Indicates whether the expense rule is updated for the given category or tag */
expenseRule: OnyxCommon.PendingAction;
}
>;
} & Partial<PendingJoinRequestPolicy>,
'addWorkspaceRoom' | keyof ACHAccount | keyof Attributes
>;
Expand Down
Loading