Skip to content

Resolves issue #1784 , Fixes false positives in joint approval change detection due to Date vs String comparison.#1793

Merged
david-rocca merged 3 commits intoupdated_ur_fieldsfrom
dr_1784
May 1, 2026
Merged

Resolves issue #1784 , Fixes false positives in joint approval change detection due to Date vs String comparison.#1793
david-rocca merged 3 commits intoupdated_ur_fieldsfrom
dr_1784

Conversation

@david-rocca
Copy link
Copy Markdown
Collaborator

Closes Issue #1784

Summary

This PR addresses an issue where hasJointApprovalChanges was incorrectly evaluating to true when submitting a complete BaseOrg document update even if no actual joint approval fields were modified. This was caused by comparing Mongoose Date objects against ISO date strings (e.g., tl_root_start_date), which lodash's _.isEqual evaluated as strictly false. This fix rectifies the logic by converting the compared data objects into primitive JSON representations prior to executing lodash deep equality checks.

Important Changes

src/repositories/baseOrgRepository.js

  • Updated getJointApprovalFields to convert the original and updated document subsets to stringified JSON formats before running the _.isEqual strict equality check.
  • Updated updateOrgFull to perform the same JSON.parse(JSON.stringify(...)) conversion when checking for changes via incomingJointApprovalKeys, successfully preventing an erroneous hasJointApprovalChanges = true flag.

Testing

Steps to manually test updated functionality, if possible

  • 1) Run npm run test:integration to ensure all existing organization update behaviors remain functional and pass.
  • 2) Send a PUT request to update an organization using a full BaseOrg JSON payload containing tl_root_start_date, ensuring the date value is unchanged.
  • 3) Verify that no unnecessary review objects are created, meaning hasJointApprovalChanges correctly evaluated to false.

Notes

  • Using JSON.parse(JSON.stringify(...)) safely handles the conversion of native Date objects to their API-compliant ISO string representations, and safely drops undefined values to treat missing keys consistently.

@david-rocca david-rocca merged commit 79182c2 into updated_ur_fields May 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants