Skip to blog content
From the notebook

Why new records vanished from our Kanban board: a status with no column

A board that draws one column per status silently drops every record whose status has no column. How a 'cleaner board' refactor hid every new prospect in a CRM, the test that would have caught it, and a grouping function and TypeScript check that make it impossible to miss.

Download .md

A Kanban board usually renders one column per status and, inside each column, the records with that status. That loop has a quiet failure mode: a record whose status has no column isn’t drawn anywhere, and nothing errors. In a CRM I built for a sales team, a refactor removed the “New” and “Contacted” columns to make the board start at “Replied”. Every prospect anyone added starts as “New”, so every new prospect disappeared from the board and couldn’t be dragged anywhere. In a test that reproduces it, the board showed 2 of 6 records with no error. The fix is to group records once and treat any record that lands in no column as a bug, plus a check that every status is either a column or deliberately hidden. In TypeScript, a satisfies Record<Status, Placement> map turns a forgotten status into a compile error.

A Kanban board that filters records per column. Six records: two New, one Contacted, one Replied, one Meeting Booked, one Converted. Columns after the refactor start at Replied, so New and Contacted have no column: the board shows 2 of 6 records, Converted is hidden on purpose, and 3 records vanish with no error. The fix: group every record once and report orphans, and check that every status is a column or deliberately hidden. A TypeScript map with satisfies Record of Status to Placement makes a forgotten status a compile error.

The bug isn’t in the column loop. It’s that nothing checks what the loop leaves out.

What happened?

The CRM’s Outreach board had a column for each prospect status. To make the board feel tidier, a change introduced a filtered list for the board:

types.ts (the change that hid new prospects)
/** Board columns: starts from Replied (excludes New, Contacted, and Converted). */
export const BOARD_STATUSES = PROSPECT_STATUSES.filter((s) => s !== "Converted" && s !== "New" && s !== "Contacted");

The board then drew BOARD_STATUSES.map(status => records.filter(r => r.status === status)). A new prospect is created with status “New”, which is no longer in that list, so its card is never rendered. The Contacts board had the same change with BOARD_LEAD_STAGES. The records were in the database the whole time; they just had nowhere to be drawn.

The existing browser tests for dragging and bulk-moving cards expect those columns, so they would have caught it; they pass again after the fix. The unit test, though, had been updated to assert the new behaviour (“board starts from Engaged, excluding New and Contacted”), so it passed while the board was broken.

How do you reproduce it?

board.mjs
export function buildBoardBuggy(records, columns) {
  return columns.map((status) => ({ status, items: records.filter((r) => r.status === status) }));
}
board.test.mjs
const records = [
  { id: 1, status: "New" },
  { id: 2, status: "New" },
  { id: 3, status: "Contacted" },
  { id: 4, status: "Replied" },
  { id: 5, status: "Meeting Booked" },
  { id: 6, status: "Converted" },
];
const trimmed = STATUSES.filter((s) => !["New", "Contacted", "Converted"].includes(s));
const shown = buildBoardBuggy(records, trimmed).reduce((n, c) => n + c.items.length, 0);
assert.equal(shown, 2); // 2 of 6 drawn: Converted is hidden on purpose, the other three are simply gone

Two of six records appear. One is hidden by design (converted prospects leave the board through a dialog). The other three vanish, and no code path notices.

How do you make a missing column impossible to miss?

Group every record once and collect the ones that fit nowhere, instead of asking each column to pick its records:

board.mjs: the fix
export function buildBoard(records, columns, { hidden = [] } = {}) {
  const board = new Map(columns.map((s) => [s, []]));
  const orphans = [];
  for (const r of records) {
    if (board.has(r.status)) board.get(r.status).push(r);
    else if (!hidden.includes(r.status)) orphans.push(r);
  }
  return { columns: [...board].map(([status, items]) => ({ status, items })), orphans };
}

export function missingColumns(statuses, columns, hidden = []) {
  return statuses.filter((s) => !columns.includes(s) && !hidden.includes(s));
}

With the trimmed columns, orphans is the two “New” records and the “Contacted” one, and missingColumns returns ["New", "Contacted"]. What you do with orphans is a product choice: log them, show an “Other” column, or fail a test. The point is that they’re counted. In development, throwing on a non-empty orphans list turns the silent bug into a loud one.

Can the type system catch it?

Yes, if each status must say where it goes. A plain array of columns can’t do that, but a map from every status to its placement can:

columns.ts
type Status = "New" | "Contacted" | "Replied" | "Converted";
type Placement = "column" | "hidden";

export const PLACEMENT = {
  New: "column",
  Contacted: "column",
  Replied: "column",
} satisfies Record<Status, Placement>;

TypeScript 6.0.3 rejects this: Property 'Converted' is missing in type ... but required in type 'Record<Status, Placement>'. Add a status to the union and forget the board, and the build fails. Hiding a status is still possible, but it has to be written down as "hidden", which is exactly the decision a reviewer should see.

What the fix in the CRM looked like

  • Every status has a column again, except Converted, which stays off the board on purpose because conversion goes through its own dialog.
  • A unit test renders the board with one brand-new record and asserts that every stage has a column and that the record appears in “New”.
  • A browser test adds a prospect through the form, finds its card in the New column and drags it to Replied, then checks the database.
  • The unit test that asserted the trimmed columns was replaced by one that asserts every stage has a column. A test changed to match new behaviour is worth a second look when the behaviour is “fewer things on screen”.

Summary

  • A board that filters records per column silently drops any record whose status has no column.
  • Group once and count orphans; treat a non-empty orphan list as a bug.
  • Check that every status is a column or explicitly hidden, at runtime or with satisfies Record<Status, Placement>.
  • Test the board with a freshly created record, since “new” is the status a cleanup is most likely to remove.

The same CRM’s backend had its own silent assumptions in tests: a fake clock and a shared table. For another place where data quietly goes missing, see rebuilding a BullMQ queue after Redis loses its data, and for a scraper that must never undo a person’s change, field locks and edit history.

Part of the guide Reliable backends in Node.js, Python and Go, which puts related articles in reading order.