Conditional motion timers

Hi there, I have a use-case I’m not sure how to achieve. I live in a townhouse where we exit through the basement, where my home office is. I have a motion sensor in the stairwell that activates the stairs, the basement, and the garage. I also want it to not change the lights in my office if I’m in there working, so I have set 2 groups, one that includes the office, and one that doesn’t.
I have a wait command in there before turning the lights off. it generally works as intended. My problem is that if we are still using the stairs where the sensor is when the ‘wait’ timer expires, it will still turn off the lights with us on the stairs.

I solved this in another area by sensing for no motion and turning the lights off then, but I can’t set conditions for whether my office lights are on or off this way.
Any suggestions on achieving this automation?

Thank you