DEV Community

Miran
Miran

Posted on

What Happens When Two People Try to Cover the Same Shift?

A product illustration showing two staff members trying to claim the same open shift, with the server deciding that one claim succeeds and the other is declined
After writing about the cover flow for missed shifts, I kept thinking about one small moment that is easy to ignore:

What happens if two people try to cover the same shift?

On the screen, the flow looks simple.

A shift needs cover.

Available staff can see it.

Someone taps “I can cover this.”

The shift becomes covered.

That is the clean version.

But real products usually get messy in the small gap between someone tapping a button and the system deciding what actually happened.


The UI can be fast, but it cannot decide the truth

The tempting version is to make the UI feel instant.

Someone taps the button, and the shift immediately looks like theirs.

That feels nice.

The product feels quick.

The action feels clear.

The user gets feedback right away.

But there is a problem.

The UI does not know if someone else tapped the same button at almost the same time.

Maybe two staff members saw the available shift.

Maybe both wanted it.

Maybe both tapped within a few seconds of each other.

If both screens show success, the product just created a new problem.

Now two people may think they are covering the same shift.

That is worse than the shift being uncovered.

Because now the owner has to clean up the confusion created by the tool.


The server should make the final call

For this kind of flow, I think the UI can feel responsive, but the server has to be the source of truth.

The staff member can tap “I can cover this.”

The app can show a loading state.

Maybe even something friendly like:

Checking availability...

But the shift should only become theirs after the server confirms it.

The backend needs to check a few things before accepting the claim.

Is this shift still open?

Does it still need cover?

Has someone else already taken it?

Is this staff member allowed to take it?

If all of that passes, the claim succeeds.

If not, the claim should fail in a normal, human way.

Not with a scary error.

Just something like:

This shift has already been covered.

That is enough.

The person does not need to know about race conditions or database locks.

They just need to know they were a little too late.


First valid claim wins

For the MVP, I would probably keep the rule simple:

First valid claim wins.

But the word “valid” matters.

It is not the first person who opened the page.

It is not the first person who saw the shift.

It is not the first person whose UI changed locally.

It is the first claim that reaches the server and passes the checks.

That feels like a good default for a small product.

It is simple enough to understand.

It avoids double assignment.

It gives the owner one clear answer.

And it keeps the staff experience straightforward.

Someone got it.

The shift is covered.

Move on.

There are more advanced versions later.

The owner could approve claims manually.

The system could rank people by distance, availability, or experience.

Some staff could get priority.

But for the first version, I would rather have one reliable rule than five clever rules that create more confusion.


The database has to protect the rule

This is the part that is not very visible in the UI, but it matters a lot.

The frontend should not be the only thing preventing two people from claiming the same shift.

Disabling the button after someone taps it is not enough.

Two requests can still arrive close together.

Someone can have the page open in two tabs.

A slow connection can make the order feel different from what actually happened.

So the backend or database needs to protect the rule.

The important idea is simple:

Only update the shift if it is still available.

If the shift has already been claimed, the second request should not overwrite it.

That sounds like a small backend detail.

But it is exactly the kind of detail that decides whether the product feels trustworthy.

A scheduling tool cannot be “mostly right” about who is assigned.

It has to be clear.


The owner should not resolve the product’s race condition

This is where the technical detail becomes a product detail.

If two people think they got the same shift, the owner is forced back into manual coordination.

They have to message one person.

Then message the other.

Then explain what happened.

Then update the schedule again.

At that point, the tool did not reduce uncertainty.

It just moved the uncertainty somewhere else.

That is the thing I want to avoid.

The whole point of the cover flow is to make a messy handoff clearer.

If the system creates another messy handoff, the feature failed.

So claim logic is not just a backend edge case.

It affects trust.

The owner needs to believe that when the tool says a shift is covered, it is actually covered.

The staff member needs to believe that when the tool says they got a shift, they really got it.


Eligibility can come later, but the shape matters now

There is another layer here too: eligibility.

Not everyone should necessarily be able to cover every shift.

Maybe someone is not available at that time.

Maybe they are too far away.

Maybe they do not know that client.

Maybe they should not see full job details until they accept.

For the first MVP, I would not try to build a full rules engine.

That feels too heavy.

But I do think the claim flow should leave room for rules later.

The basic question is not only:

Can this shift be claimed?

It is also:

Can this person claim this shift?

That is a slightly different product shape.

Even if the first version only checks simple things, the model should probably be ready for more specific rules later.


The flow I am thinking about

The claim flow in my head looks like this:

Staff taps “I can cover this”

The app sends the claim request

The server checks whether the shift still needs cover

The server checks whether this person is allowed to claim it

If yes, the shift becomes reassigned

If no, the staff member sees that the shift is no longer available

The owner sees one clear covered state

Nothing fancy.

But it solves the important part.

Only one person gets the shift.

The schedule stays clear.

The owner does not need to clean up the product’s mistake.


What I learned from thinking about this

This is one of those features where the UI makes the problem look smaller than it is.

A button can look simple.

A card can move from one state to another.

A shift can look covered.

But the real product is the rule behind the movement.

Who is allowed to claim it?

What happens if two people try at the same time?

Who gets the final state?

What does the second person see?

What does the owner need to know?

That is the part I want to get right.

Not in an overbuilt way.

Just enough so the product does not create more confusion when real life gets messy.

For small tools, I keep finding that the most important work is not always the screen.

Sometimes it is the quiet rule behind the screen.

Top comments (0)