I think you're getting a little messed up here. The first equality is OK, but not the second. Note these:
---------------------------
She has to stay. = She must stay. = She cannot leave.
She has to leave. = She must leave. = She cannot stay.
She had to stay. = She could not leave.
She had to leave. = She could not stay.
_______
She does not have to stay. = She need not stay. = She can leave.
She does not have to leave. = She need not leave. = She can stay.
She did not have to stay. = She need not have stayed. = She could have left.
She did not have to leave. = She need not have left. = She could have stayed.
______
It has to be Bob. = It must be Bob. = It cannot be anyone but Bob. = It can only be Bob.
It
doesn't have to be Bob. = It isn't necessarily Bob. = It need not be
Bob. = It [may / might / can / could] be someone other than Bob. = It [may / might] not be Bob.
It had to be Bob. = It must have been Bob. = It could not have been anyone but Bob. = It could only have been Bob.
It didn't have to be Bob. = It wasn't necessarily Bob. = It
needn't have been Bob. = It [may / might / could] have been someone
other than Bob.= It [may / might] not have been Bob.
____________
It [may / might / could] be Bob. = It is possible that it is Bob.
It
[may / might] not be Bob. = It is possible that it is not Bob. = It
[may / might / could] be someone other than Bob. = It is not
necessarily Bob.
It
[can't / couldn't] be Bob. = It is not possible that it is Bob. = It
has to be someone other than Bob. = It must be someone other than Bob.
= It [can / could] only be someone other than Bob.
It [may / might / could] have been Bob. = It is possible that it was Bob.
It [may / might] not have been Bob. = It is possible that it was
not Bob. = It [may / might / could] have been someone other than Bob. = It was not necessarily Bob.
It [can't / couldn't] have been Bob. = It is not possible that it
was Bob. = It had to be someone other than Bob. = It must have been
someone other than Bob. = It [can / could] only have been someone other
than Bob.
_____
Be careful about where the not's are! There are often two possible negations to a sentence! And note that all those with stay and leave have to do with obligations and permissions; all those with Bob have to do with logical relationships.
CJ