Dishwasher won't drain

There is about 2 inches of dirty water remaining after the complete cycle. I removed the machine and set it up in the garage to diagnose. The drain hose is not clogged. I removed the pump and applied power with a test wire. The pump starts and runs. I removed the pump cover and the impeller is fine. I have not clipped a volt meter to the pump leads yet to see if it’s being energized, but assume it is not. Not a drop comes out of the drain hose, yet it doesn’t overflow. What tells it when to fill/run/drain?