How to Mate Old Subfloor with New Plywood?
I see you have 3 layers of flooring that was under the old tile. The top layer I see the cement board, under that the underlayment, and under that on top of the joists, the subfloor.

To get a good tie in to the existing, use a right angle grinder or circular saw with the proper blade, and cut back the cement backer about an inch away from tile floor coming through the doorway from the other room. If it is not tile, like I think it is and there is a joint somewhere close to what I described earlier, remove the material up to that joint then. That looks like it may leave about 3-4 inches of plywood underlayment exposed after the cement board is cut and removed. Next set the circular saw to depth for the thickness of the plywood underlayment and make a cut about 1 1/2-2" away from the cement board, finish the cut to the side of the door rough opening with a multimaster or reciprocating saw if you can control the depth of cut, and remove that small piece. Do nothing with the subfloor. Add screws along the edge of underlayment to secure it to the subfloor. Add the ledgers/sister joist, the subfloor. When cutting the underlayment, make sure it is one piece going into the doorway and out into the bathroom a ways so the joints in the underlayment and subfloor do not line up. Use screws to hold the underlayment to the subfloor, use construction adhesive if you choose to as well. The screws go in at 4-6" on the perimeter, 8-10" in both directions in the middle. Do not concern yourself with those screws going into the joists, it is better if they do not. 1 1/2" or so long screws will do well there.

I typically gap all my plywood that is not T&amp;G about 1/8" on all edges. when it is T&amp;G, I still gap the ends 1/8"