Fixing a Multi-Level Incentive System (L1-L4) Without Breaking the Workflow
How I debugged and stabilized a hierarchical incentive system with approval, hold, and reporting logic across multiple roles.
This started as one of those systems that looked perfect on paper.
A 4-level incentive flow. L1 to L4. Each level approves, moves forward, everything clean.
Then I tested it with real scenarios.
Things didn't break completely. They just behaved… wrong in small ways.
That was worse.
The original goal
The idea was simple:
- L1 (Sales) creates incentives
- L2 (Team Lead) reviews
- L3 (Manager) reviews
- L4 (Owner) finalizes
Each level should:
- Only see items after the previous level approves
- Be blocked if something below is on hold
- Continue properly once things are reopened
Sounds straightforward.
It wasn't.
Where things went wrong
The biggest issue was this:
Database state and UI behavior were not aligned
Some examples:
- L2 could see items that L1 had not approved
- Holds were not properly blocking higher levels
- L3 and L4 were seeing items they should not touch
- Reports showed everything, even irrelevant states
Nothing was fully broken. But nothing was fully correct either.
The core realization
I was trusting raw database fields too much:
statusholdReasonheldBy
Those values were technically correct, but not enough to represent the actual workflow.
So I introduced a derived layer:
Effective State
Effective State
Instead of using the row as-is, I compute what the state should be based on lower levels in the same sale.
Basic idea:
function computeEffectiveState(inc) {
const lowerHeld = checkLowerLevelHold(inc)
if (lowerHeld) {
return {
effectiveStatus: "ON_HOLD",
effectiveHeldBy: lowerHeld.heldBy
}
}
return {
effectiveStatus: inc.status
}
}