Same thing happened to my friends in U.S. they needed to transfer the flight in Canada and departed from U.S., since they don't have a valid visa to enter Canada, the airline refused them to aboard. But some exceptions happened--one friend, his U.S. visa is valid, then he got on the plane. so it depends. you should ask somebody who is a professional or at least had similar experience previously. Others' might not fit yours.