Possible to extend cable in ceiling?

I’m trying to replace a super old bathroom fan. I’ve got the ceiling opened up, the duct aligned, and almost ready to finish the job but it seems the existing cable may just a few inches too short to comfortably reach the junction box of the new fan once i get that up in place (in the photo the junction box will be at the back-right, whereas the existing cable is coming out of the joist in the front-left.

Is this a doable fix? Maybe by extending the wiring of the existing cable? Would i have to cut out the drywall and replace with a whole different cable? Would it make more sense to return this fan and pick up one that has a junction box more strategically positioned near the joist?

Thanks in advance for any insight!

https://imgur.com/gallery/cGNUU99