Fix middleware notFound: true handling (#46759)
This ensures we properly handle rendering the `404` page when `notFound:
true` is returned and middleware is present.
## Bug
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
Fixes: https://github.com/vercel/next.js/issues/38239
x-ref: https://github.com/vercel/next.js/issues/43772
---------
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>