From 7fcc94b811dcd16b5fc58ddd4e9061647a87c695 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 1 Oct 2024 08:33:11 +0100 Subject: [PATCH 1/5] add reimbursement types to Policy --- src/types/onyx/Policy.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index f2604d723f05..392e196e9c60 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1488,6 +1488,14 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** The reimbursement choice for policy */ reimbursementChoice?: ValueOf; + /** reimbursement options */ + reimbursement?: { + /** The reimbursement choice for policy */ + choice?: { + reimbursementChoice?: ValueOf; + } + } + /** Detailed settings for the autoReimbursement */ autoReimbursement?: OnyxCommon.OnyxValueWithOfflineFeedback< { From 63cab3b4cd8707fece05df6235e315b1159285b4 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 1 Oct 2024 08:34:20 +0100 Subject: [PATCH 2/5] update reimbursement choice entry --- src/libs/ReportUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a5519dc9e186..55ca51951d06 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1629,12 +1629,13 @@ function isPayer(session: OnyxEntry, iouReport: OnyxEntry) { const policyType = policy?.type; const isAdmin = policyType !== CONST.POLICY.TYPE.PERSONAL && policy?.role === CONST.POLICY.ROLE.ADMIN; const isManager = iouReport?.managerID === session?.accountID; + const reimbursementChoice = policy?.reimbursement?.choice?.reimbursementChoice ?? policy?.reimbursementChoice; if (isPaidGroupPolicy(iouReport)) { - if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES) { + if (reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES) { const isReimburser = session?.email === policy?.achAccount?.reimburser; return (!policy?.achAccount?.reimburser || isReimburser) && (isApproved || isManager); } - if (policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) { + if (reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_MANUAL) { return isAdmin && (isApproved || isManager); } return false; From 53f6d2a7c58ea88b77d9ed58aec4b401fe1c6d26 Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 1 Oct 2024 08:35:28 +0100 Subject: [PATCH 3/5] fix formatting with prettier --- src/types/onyx/Policy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 392e196e9c60..c8017db0075a 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1493,8 +1493,8 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** The reimbursement choice for policy */ choice?: { reimbursementChoice?: ValueOf; - } - } + }; + }; /** Detailed settings for the autoReimbursement */ autoReimbursement?: OnyxCommon.OnyxValueWithOfflineFeedback< From e83d75b1957a7c22bf669418753bafa9ce55fffe Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 1 Oct 2024 08:56:04 +0100 Subject: [PATCH 4/5] fix JSDoc --- src/types/onyx/Policy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index c8017db0075a..32f661a92c70 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1492,6 +1492,7 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< reimbursement?: { /** The reimbursement choice for policy */ choice?: { + /** The reimbursement choice for policy */ reimbursementChoice?: ValueOf; }; }; From efb105675e2c7aa5ba6364bc68f3c6da5615020d Mon Sep 17 00:00:00 2001 From: Etotaziba Olei Date: Tue, 1 Oct 2024 08:59:08 +0100 Subject: [PATCH 5/5] fix lint --- src/types/onyx/Policy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 32f661a92c70..4ec0be01f7ea 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1492,7 +1492,7 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< reimbursement?: { /** The reimbursement choice for policy */ choice?: { - /** The reimbursement choice for policy */ + /** The reimbursement choice for policy */ reimbursementChoice?: ValueOf; }; };