mice and sound traveling through brick party wall joist pockets
The right way to do that would be to use metal flashing, fabricated to go around the joists and abut the pockets. Fill the spaces with metal screen or coarse steel wool (to discourage rodent teeth), followed by the foam for sound deadening, then seal it up with the metal flashing, bent to go flush against the brick and nailed into the joists.