This question is difficult to answer but i will try.
Oral minoxidil is not necessary for surgery itself to be successful. a good surgery should stand alone by itself without minoxidil.
If you take minoxidil your results will look more "wow" since it will beef up your hair both the transplanted and existing i.e. Each strand will be thicker. so for eg. let us say your average hair shaft is 65 um, with minoxidil it maybe 75 um. this small difference can result in a big visual difference cosmetically. Also more % of follicles will be in Anagen phase.
However when you stop taking the minoxidil, it will go back to the way it was going to be without minoxidil. Meaning if you dont want to take it forever, no point in taking it and stopping.
5 mg is a hefty dose. I would not take it forever. but that is just my personal opinion.
Medications are more a strategy to combat further hair loss. That is the main use for them, not so much for the success of surgery.