fix(toggleMultiple): avoid vacuous-truth disable when no orgUnit toggles#186
Open
MiquelAdell wants to merge 2 commits intodevelopmentfrom
Open
fix(toggleMultiple): avoid vacuous-truth disable when no orgUnit toggles#186MiquelAdell wants to merge 2 commits intodevelopmentfrom
MiquelAdell wants to merge 2 commits intodevelopmentfrom
Conversation
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.
BundleMonNo change in files bundle size Groups updated (1)
Final result: ✅ View report in BundleMon website ➡️ |
MatiasArriola
approved these changes
May 5, 2026
Contributor
MatiasArriola
left a comment
There was a problem hiding this comment.
The fix is correct and safe.
[].every(() => false) is true, so we were incorrectly returning true there.
Thanks @MiquelAdell!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task:
https://app.clickup.com/t/869d5pkq2
Summary
toggleMultiplesection was disabled whenlogicalOperator: "AND"was combined with onlydataElement-type toggles (no orgUnit toggles).isToggleMultipleDeDisabledfilteredtoggleDataElementsdown to orgUnit entries matching the data element, then evaluated with.every(). With an empty array,[].every(...)is vacuouslytrue, locking the section regardless of toggle state.falsewhen there are no matching orgUnit toggles, so the function only ever returnstruebecause an actual orgUnit-disable rule applied.Regression introduced in #148.
Repro
Reported by Ryan (WHO MAL): the WMR
MAL_WMR_LAB_DBL_COUNT_GRIDsection (Double counted figuresunderTOTAL MALARIA CASES) had allPublic/Private/Community/Combinedcells forMAL_MICR_RDT_DOUBLE_COUNT_TESTandMAL_MICR_RDT_DOUBLE_COUNT_POSlocked even when the upstream Yes/No questions (MAL_MICR_RDT_DOUBLE_COMB,MAL_MICRDTDOUBLECOUNTFIGURESKNOWNCOMB) were Yes. The deployed datastore configures this section withlogicalOperator: "AND"and twodataElement-type conditions, hitting the vacuous-truth path.Test plan
src/domain/common/entities/__tests__/ToggleMultiple.spec.tspass.dataSetId=CWuqJ3dtQC4,orgUnit=hmZE3mVAZFf,period=2025): the 8 number inputs inDouble counted figuresare nowdisabled: falseand editable.dataSetId=XGn6mrO2HU8) is unaffected — its sections uselogicalOperator: "OR"with orgUnit-type toggles, neither condition triggers the new early-return.🤖 Generated with Claude Code