The 31-year-old Williams played in the All Blacks tense 22-19 victory over Ireland in their second test match in Christchurch on Saturday. He had been bothered with pain in the knee for at least two weeks, Hansen said.
"It has got to the point where we think it is better for him to get it operated on," Hansen told reporters at the team hotel in Christchurch.
"It's about six to eight weeks minimum but we think if we use the time now he should be back for the (Four Nations).
"Everyone else has bumps and bruises and is a bit sore but is fit for selection."
The All Blacks will not call anyone else into the squad for the final test in Hamilton next Saturday, suggesting Luke Romano could make his test debut off the bench.
Loose forward Liam Messam was already joining the team as cover for the injured Victor Vito and possibly for number eight Kieran Read, who was substituted at halftime on Saturday after suffering a head knock, Hansen said.
Hansen said Read would be monitored for concussion and would not be risked if not 100 percent ready.
Hooker Keven Mealamu had recovered from a calf injury and would be available for selection next week, with Hika Elliott dropping out of the squad.
New Zealand have already won the three-match series against Ireland after they won the first game 42-10 in Auckland on June 9