Skip to content

Commit e68e040

Browse files
authored
Merge pull request #49049 from software-mansion-labs/fix/category-rules-fixes
Fix editing Approver offline and description for Individual expense in "Flags amount over"
2 parents 0f9fb1c + c738846 commit e68e040

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed

src/libs/actions/Policy/Category.ts

+22-14
Original file line numberDiff line numberDiff line change
@@ -1180,8 +1180,10 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro
11801180
value: {
11811181
rules: {
11821182
approvalRules: updatedApprovalRules,
1183-
pendingFields: {
1184-
approvalRules: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
1183+
},
1184+
pendingRulesUpdates: {
1185+
[categoryName]: {
1186+
approvalRule: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
11851187
},
11861188
},
11871189
},
@@ -1192,9 +1194,9 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro
11921194
onyxMethod: Onyx.METHOD.MERGE,
11931195
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
11941196
value: {
1195-
rules: {
1196-
pendingFields: {
1197-
approvalRules: null,
1197+
pendingRulesUpdates: {
1198+
[categoryName]: {
1199+
approvalRule: null,
11981200
},
11991201
},
12001202
},
@@ -1207,8 +1209,10 @@ function setPolicyCategoryApprover(policyID: string, categoryName: string, appro
12071209
value: {
12081210
rules: {
12091211
approvalRules,
1210-
pendingFields: {
1211-
approvalRules: null,
1212+
},
1213+
pendingRulesUpdates: {
1214+
[categoryName]: {
1215+
approvalRule: null,
12121216
},
12131217
},
12141218
},
@@ -1260,8 +1264,10 @@ function setPolicyCategoryTax(policyID: string, categoryName: string, taxID: str
12601264
value: {
12611265
rules: {
12621266
expenseRules: updatedExpenseRules,
1263-
pendingFields: {
1264-
expenseRules: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
1267+
},
1268+
pendingRulesUpdates: {
1269+
[categoryName]: {
1270+
expenseRule: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE,
12651271
},
12661272
},
12671273
},
@@ -1272,9 +1278,9 @@ function setPolicyCategoryTax(policyID: string, categoryName: string, taxID: str
12721278
onyxMethod: Onyx.METHOD.MERGE,
12731279
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
12741280
value: {
1275-
rules: {
1276-
pendingFields: {
1277-
expenseRules: null,
1281+
pendingRulesUpdates: {
1282+
[categoryName]: {
1283+
expenseRule: null,
12781284
},
12791285
},
12801286
},
@@ -1287,8 +1293,10 @@ function setPolicyCategoryTax(policyID: string, categoryName: string, taxID: str
12871293
value: {
12881294
rules: {
12891295
expenseRules,
1290-
pendingFields: {
1291-
expenseRules: null,
1296+
},
1297+
pendingRulesUpdates: {
1298+
[categoryName]: {
1299+
expenseRule: null,
12921300
},
12931301
},
12941302
},

src/pages/workspace/categories/CategorySettingsPage.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ function CategorySettingsPage({
257257
/>
258258
</OfflineWithFeedback>
259259
)}
260-
<OfflineWithFeedback pendingAction={policy?.rules?.pendingFields?.approvalRules}>
260+
<OfflineWithFeedback pendingAction={policy?.pendingRulesUpdates?.[categoryName]?.approvalRule}>
261261
<MenuItemWithTopDescription
262262
title={approverText}
263263
description={translate('workspace.rules.categoryRules.approver')}
@@ -281,7 +281,7 @@ function CategorySettingsPage({
281281
</Text>
282282
)}
283283
{policy?.tax?.trackingEnabled && (
284-
<OfflineWithFeedback pendingAction={policy?.rules?.pendingFields?.expenseRules}>
284+
<OfflineWithFeedback pendingAction={policy?.pendingRulesUpdates?.[categoryName]?.expenseRule}>
285285
<MenuItemWithTopDescription
286286
title={defaultTaxRateText}
287287
description={translate('workspace.rules.categoryRules.defaultTaxRate')}

src/pages/workspace/categories/ExpenseLimitTypeSelector/ExpenseLimitTypeSelectorModal.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ function ExpenseLimitTypeSelectorModal({isVisible, currentExpenseLimitType, onEx
6565
shouldSingleExecuteRowSelect
6666
containerStyle={[styles.pt3]}
6767
initiallyFocusedOptionKey={currentExpenseLimitType}
68+
isAlternateTextMultilineSupported
69+
alternateTextNumberOfLines={3}
6870
/>
6971
</ScreenWrapper>
7072
</Modal>

src/types/onyx/Policy.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,9 @@ type ExpenseRule = {
14121412
id?: string;
14131413
};
14141414

1415+
/** The name of the category or tag */
1416+
type CategoryOrTagName = string;
1417+
14151418
/** Model of policy data */
14161419
type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<
14171420
{
@@ -1586,13 +1589,13 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback<
15861589
taxRates?: TaxRatesWithDefault;
15871590

15881591
/** A set of rules related to the workpsace */
1589-
rules?: OnyxCommon.OnyxValueWithOfflineFeedback<{
1592+
rules?: {
15901593
/** A set of rules related to the workpsace approvals */
15911594
approvalRules?: ApprovalRule[];
15921595

15931596
/** A set of rules related to the workpsace expenses */
15941597
expenseRules?: ExpenseRule[];
1595-
}>;
1598+
};
15961599

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

16841687
/** Workspace account ID configured for Expensify Card */
16851688
workspaceAccountID?: number;
1689+
1690+
/** Information about rules being updated */
1691+
pendingRulesUpdates?: Record<
1692+
CategoryOrTagName,
1693+
{
1694+
/** Indicates whether the approval rule is updated for the given category or tag */
1695+
approvalRule: OnyxCommon.PendingAction;
1696+
1697+
/** Indicates whether the expense rule is updated for the given category or tag */
1698+
expenseRule: OnyxCommon.PendingAction;
1699+
}
1700+
>;
16861701
} & Partial<PendingJoinRequestPolicy>,
16871702
'addWorkspaceRoom' | keyof ACHAccount | keyof Attributes
16881703
>;

0 commit comments

Comments
 (0)