Securing exhaust fan housing from inside the housing?

Long story short, I'm moving the exhaust fan in my laundry room back 4" so I have clearance for new cabinets.

When I opened up the ceiling I finally discovered where it was fastened (first image). When I move the fan back, that area for fastening will get covered up by ceiling. CAN I fasten the housing by screwing directly from inside the housing into the joist (second image)? I think I recall one of the other exhaust fans in my house being secured this way but can't recall tbh and not even sure if that's allowed.

Hopefully this makes sense.

Thank you!

P.S. I know I could cut back more drywall to secure from the correct location but I'm trying to avoid having multiple patches lol