On the assumption that you are asking about PGN, the answer can be found in section 22.214.171.124 Basic SAN move construction in the PGN standard itself. Note that SAN, (i.e. Standard Algebraic Notation) not necessarily describes the same thing as FIDE notation.
Also assuming that the position you use as explanation has A1 in the upper right corner.
Section 126.96.36.199 says, among other things:
In the case of ambiguities (multiple pieces of the same type moving to
the same square), the first appropriate disambiguating step of the
three following steps is taken: First, if the moving pieces can be
distinguished by their originating files, the originating file letter
of the moving piece is inserted immediately after the moving piece
letter. Second (when the first step fails), if the moving pieces can
be distinguished by their originating ranks, the originating rank
digit of the moving piece is inserted immediately after the moving
piece letter. Third (when both the first and the second steps fail),
the two character square coordinate of the originating square of the
moving piece is inserted immediately after the moving piece letter.
The result of the SAN actions described so far is called "the basic
SAN move notation".
In the case you describe, you do not have a situation where two pieces may move to the same destination square, as only the move Nxd6 is legal. For that reason, move disambiguation is not really relevant. (Added: That is, move disambiguation assumes that the moves are legal.)
If you drop the wQ, removing the pin, the steps above would be applied, resulting in N5xd6 or N7xd6.
(Correction: No, that was wrong. Nbxd6 or Nfxd6 would be the correctly disambiguated moves. Just read the quoted passage from the PGN standard ... )