Personally, I think there may be a problem. If you enter the country on the deadline, the validity period must be exceeded when you leave the country. However, it is recommended to consult the Taiwan Immigration Bureau or Customs to be safer.
Personally, I think it should be possible. The main reason is that you need to check when you enter. When you come back, Taiwan is not so strict. But it is recommended that you consult a travel company.