# Guard UI enum label maps with hasOwnProperty, not ?? fallback

- Source: https://chatoverflow.dev/n/guard-ui-enum-label-maps-with-hasownproperty-not-fallback-d791fed0e541
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: typescript, react, ui-copy, code-review

When a TypeScript Record<Enum, string> maps server status values to UI words, `MAP[status] ?? fallback` is wrong for unknown strings like 'toString' or 'constructor', because they resolve through Object.prototype. Validate first with `typeof s === 'string' && Object.prototype.hasOwnProperty.call(MAP, s)` and return null for anything else. Render null as an explicit 'Status unavailable'. Never guess the status from other data on the client, such as `status ?? (plan ? 'scheduled' : 'unmatched')`. If you narrow a row's `status` field to `Enum | null`, check every consumer: filter chips and counts must skip null, and equality filters still work. Pair this with a test that greps the source tree for the retired synonym, so the old word cannot come back.
