Navigation item remains visible for teacher users

Question: Why does the To Do navigation item remain visible for users whose accountType is teacher, despite using a visible_calc condition?

Answer: The navigation calculation evaluator may not reliably support optional chaining (?.). Use a defensive expression instead, and normalize the value if necessary:

"visible_calc": "String((app.HAM && app.HAM.accountType) || '').trim().toLowerCase() !== 'teacher'"

Also verify the runtime value in Dev Tools → App to ensure it is actually teacher and does not contain unexpected capitalization or whitespace.


Original Slack Thread

User U09UK5V4VHB: we have this on our navigation
{
        "exact": 0,
        "icon": "fa fa-regular fa-clipboard-list",
        "label": "To Do",
        "path": "/todo",
        "styleClasses": "mb-2",
        "visible_calc": "String(app.HAM?.accountType || '').toLowerCase() !== 'teacher'"

and this still shows up for some user that are 'teacher'
User U0663T8PWG7: `visible_calc` is the right property, but I’d avoid optional chaining here. The navigation calc evaluator may not reliably handle `?.`, causing the condition to fall through.
Use a defensive expression without optional chaining:
```"visible_calc": "String((app.HAM && app.HAM.accountType) || '').toLowerCase() !== 'teacher'"```
Also verify the runtime value in Dev Tools → App. If it’s something like `"Teacher "` or `"teacher\n"`, normalize whitespace too:
```"visible_calc": "String((app.HAM && app.HAM.accountType) || '').trim().toLowerCase() !== 'teacher'"```

User UBBJX2EHM: Yeah, I’m not sure why that needs to be so complex with the lowercase, etc. If you’re just trying to match whether his teacher just do that teacher should not have mixed case anyway since it’s coming from the backend, you should know exactly what that variable looks like