Skip to content

fix(toggleMultiple): avoid vacuous-truth disable when no orgUnit toggles#186

Open
MiquelAdell wants to merge 2 commits intodevelopmentfrom
fix/togglemultiple-de-disabled-vacuous-truth
Open

fix(toggleMultiple): avoid vacuous-truth disable when no orgUnit toggles#186
MiquelAdell wants to merge 2 commits intodevelopmentfrom
fix/togglemultiple-de-disabled-vacuous-truth

Conversation

@MiquelAdell
Copy link
Copy Markdown
Contributor

@MiquelAdell MiquelAdell commented May 5, 2026

Task:

https://app.clickup.com/t/869d5pkq2

Summary

  • Fix regression where every cell in a toggleMultiple section was disabled when logicalOperator: "AND" was combined with only dataElement-type toggles (no orgUnit toggles).
  • isToggleMultipleDeDisabled filtered toggleDataElements down to orgUnit entries matching the data element, then evaluated with .every(). With an empty array, [].every(...) is vacuously true, locking the section regardless of toggle state.
  • Short-circuits to false when there are no matching orgUnit toggles, so the function only ever returns true because an actual orgUnit-disable rule applied.

Regression introduced in #148.

Repro

Reported by Ryan (WHO MAL): the WMR MAL_WMR_LAB_DBL_COUNT_GRID section (Double counted figures under TOTAL MALARIA CASES) had all Public/Private/Community/Combined cells for MAL_MICR_RDT_DOUBLE_COUNT_TEST and MAL_MICR_RDT_DOUBLE_COUNT_POS locked even when the upstream Yes/No questions (MAL_MICR_RDT_DOUBLE_COMB, MAL_MICRDTDOUBLECOUNTFIGURESKNOWNCOMB) were Yes. The deployed datastore configures this section with logicalOperator: "AND" and two dataElement-type conditions, hitting the vacuous-truth path.

Test plan

  • Existing unit tests in src/domain/common/entities/__tests__/ToggleMultiple.spec.ts pass.
  • Verified live (HMR) on the WMR form (dataSetId=CWuqJ3dtQC4, orgUnit=hmZE3mVAZFf, period=2025): the 8 number inputs in Double counted figures are now disabled: false and editable.
  • Verified TUB Annual section 6 (dataSetId=XGn6mrO2HU8) is unaffected — its sections use logicalOperator: "OR" with orgUnit-type toggles, neither condition triggers the new early-return.

🤖 Generated with Claude Code

isToggleMultipleDeDisabled filters toggleDataElements down to orgUnit
entries matching the data element, then evaluates with .every() under
AND. When no orgUnit toggles match, [].every(...) is vacuously true and
disables every cell in the section — even though no orgUnit-disable rule
applies. Sections configured with logicalOperator: "AND" plus only
dataElement-type toggles (e.g. MAL_WMR_LAB_DBL_COUNT_GRID) had all
inputs locked despite the toggle conditions being met.

Short-circuit to false when there are no matching orgUnit toggles, so
the function only ever returns true via an actual orgUnit-disable rule.

Regression introduced in #148.
@MiquelAdell MiquelAdell requested a review from MatiasArriola May 5, 2026 10:52
@bundlemon
Copy link
Copy Markdown

bundlemon Bot commented May 5, 2026

BundleMon

No change in files bundle size

Groups updated (1)
Status Path Size Limits
Build Folder
./**/*
1.52MB (+11B 0%) +20%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

Copy link
Copy Markdown
Contributor

@MatiasArriola MatiasArriola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct and safe.

[].every(() => false) is true, so we were incorrectly returning true there.

Thanks @MiquelAdell!

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