- Make function synchronous and remove database dependency
- Accept lastNonPendingStatus as parameter instead of monitorID
- Simplify function logic for better testability
- Update call sites to fetch lastNonPendingStatus only when needed
- Add comprehensive test suite with 17 test cases covering all status transitions
Addresses code review feedback about function complexity and testability