diff --git a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts index 55f2db9f784cd..db08a66bf270c 100644 --- a/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts +++ b/src/pages/ReimbursementAccount/NonUSD/utils/getSignerDetailsAndSignerFilesForSignerInfo.ts @@ -22,6 +22,10 @@ const signerDetailsFields = [FULL_NAME, EMAIL, JOB_TITLE, DATE_OF_BIRTH, STREET, const signerFilesFields = [PROOF_OF_DIRECTORS, ADDRESS_PROOF, COPY_OF_ID, CODICE_FISCALE]; const beneficialOwnerFields = [FIRST_NAME, LAST_NAME, DOB, BENEFICIAL_STREET, BENEFICIAL_CITY, BENEFICIAL_STATE, BENEFICIAL_ZIP_CODE]; +// These fields are required by the backend and must always be included in the request +// so that proper validation errors can be returned if they're missing +const requiredSignerFields = new Set([FULL_NAME, DATE_OF_BIRTH, JOB_TITLE]); + function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: OnyxEntry, signerEmail: string, isUserBeneficialOwner: boolean) { const signerDetails: Record = {}; const signerFiles: Record = {}; @@ -32,18 +36,28 @@ function getSignerDetailsAndSignerFilesForSignerInfo(reimbursementAccountDraft: continue; } - if (!reimbursementAccountDraft?.[fieldName]) { + if (fieldName === STREET || fieldName === CITY || fieldName === STATE || fieldName === ZIP_CODE) { + if (reimbursementAccountDraft?.[fieldName]) { + signerDetails[ADDRESS] = signerDetails[ADDRESS] + ? `${SafeString(signerDetails[ADDRESS])}, ${SafeString(reimbursementAccountDraft?.[fieldName])}` + : SafeString(reimbursementAccountDraft?.[fieldName]); + } continue; } - if (fieldName === STREET || fieldName === CITY || fieldName === STATE || fieldName === ZIP_CODE) { - signerDetails[ADDRESS] = signerDetails[ADDRESS] - ? `${SafeString(signerDetails[ADDRESS])}, ${SafeString(reimbursementAccountDraft?.[fieldName])}` - : reimbursementAccountDraft?.[fieldName]; + // Preserve type for DOWNLOADED_PDS_AND_FSG since they are boolean values + if (fieldName === DOWNLOADED_PDS_AND_FSG) { + if (reimbursementAccountDraft?.[fieldName]) { + signerDetails[fieldName] = reimbursementAccountDraft[fieldName]; + } continue; } - signerDetails[fieldName] = reimbursementAccountDraft?.[fieldName]; + // Always include required fields (with empty string if not present) so Auth validation can catch them + // For non-required fields, only include if they have a value + if (requiredSignerFields.has(fieldName) || reimbursementAccountDraft?.[fieldName]) { + signerDetails[fieldName] = SafeString(reimbursementAccountDraft?.[fieldName]); + } } if (isUserBeneficialOwner) {