Although R is changed to a large one and both R and P are given, the same issue still exists.
pts=np.array([[ 0., 639., 0., 639.],
[ 0., 0., 479., 479.],
[ 1., 1., 1., 1.]])
K=np.array([[536.86303957, 0. , 338.54127669],
[ 0. , 537.17967509, 231.541806 ],
[ 0. , 0. , 1. ]])
R=cv2.Rodrigues(np.array([-.1,.1,.3]))[0]
P=np.array([[538.40307187, 0. , 341.6945076 , 0. ],
[ 0. , 538.40307187, 243.63676453, 0. ],
[ 0. , 0. , 1. , 0. ]])
#only R is given without P
pts_0=cv2.undistortPoints(pts[:2], K, None, None, None)
pts_1=cv2.undistortPoints(pts[:2], K, None, R, None)
print(np.allclose(pts_0, pts_1)) #True
#both R and P are given
pts_2=cv2.undistortPoints(pts[:2], K, None, R, P[:3,:3])
temp=np.ones((3,4))
temp[:2]=pts_0.squeeze().T
temp=P[:3,:3]@temp
print(np.allclose(temp[:2]/temp[-1],pts_2.squeeze().T)) #True