Skip to content

fix(growers): resolve org not set filter not applying in grower module - #1229

Open
yasiru98 wants to merge 1 commit into
Greenstand:masterfrom
yasiru98:fix/1044-grower-filter-org-not-set
Open

fix(growers): resolve org not set filter not applying in grower module#1229
yasiru98 wants to merge 1 commit into
Greenstand:masterfrom
yasiru98:fix/1044-grower-filter-org-not-set

Conversation

@yasiru98

Copy link
Copy Markdown

Description

  • Fixes an issue where selecting "Not set" in the Organization filter on the Growers page had no effect. It returned the same results as "All".
  • In SelectOrg.js, handleChange only searched orgList which only includes real orgs loaded from the API when looking up the selected org object. "Not set" is a hardcoded option in defaultOrgList, not a real org, so it was never found. This caused handleSelection to be called with the raw string 'ORGANIZATION_NOT_SET' instead of the object. The filter callback in FilterTopGrower.js tried to read .id off that string, got undefined, and the filter was lost before it reached the API.
  • Fixed by searching both defaultOrgList and orgList in SelectOrg.js so "Not set" is correctly resolved to its object and passed through the filter chain, resulting in organizationId: null in the API call.
  • Updated EditGrower.js to explicitly convert ORGANIZATION_NOT_SET to null when saving, preserving the correct behaviour of unsetting a grower's organization via the edit.

Issue(s) addressed

What kind of change(s) does this PR introduce?

  • Bug fix

Please check if the PR fulfils these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Issue

What is the current behavior?

Selecting "Not set" in the Organization filter on the Growers page sends an API call identical to "All". organizationId is absent from the where clause, so all growers are returned regardless of whether they have an org assigned.

bug1

Editing a grower and setting their organization to "Not set" incorrectly sent the string 'ORGANIZATION_NOT_SET' to the API instead of null, which would fail to unset the org.

bug2

What is the new behavior?

Selecting "Not set" in the filter sends "organizationId": null in the API where clause, returning only growers with no organization assigned.

fix1

Editing a grower and setting their organization to "Not set" now correctly sends organizationId: null to the API, unsetting the org as expected.

fix2

Breaking change

Does this PR introduce a breaking change?

No.

Other useful information

Root cause: SelectOrg.js searched only orgList (API-loaded orgs) in handleChange, missing the hardcoded "Not set" entry in defaultOrgList. When not found, the fallback passed the raw string 'ORGANIZATION_NOT_SET' to the callback. Callers expecting an object called .id on a string got undefined, which is dropped by JSON.stringify, leaving no org filter in the API call.

The EditGrower.js fix is required because that component needs null sent directly to the API to unset an org, whereas filter components use 'ORGANIZATION_NOT_SET' as a sentinel for the filter model.

@yasiru98
yasiru98 requested a review from a team as a code owner July 10, 2026 00:17
@cynthiabondi
cynthiabondi requested a review from dadiorchen July 13, 2026 07:43
@cynthiabondi cynthiabondi moved this to Ready for Test in Admin Panel Jul 13, 2026
@cynthiabondi cynthiabondi added the tool: Growers Relates to the Grower Management tool (Growers page, formerly Planters) label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool: Growers Relates to the Grower Management tool (Growers page, formerly Planters)

Projects

Status: Ready for Test

Development

Successfully merging this pull request may close these issues.

Grower module filter organization "not set" does not work

2 participants