President-elect Donald Trump has officially nominated retired Gen. John Kelly to lead the Department of Homeland Security — a long-dysfunctional agency that’s going to be responsible for implementing many of Trump’s most bragged-about policies, from preventing terrorism to building a “big, beautiful wall” along the US/Mexico border.

But the way Kelly sees the world, and his potential next job, goes way beyond the border or the wall. He sees the challenges to US security as holistic and regional — and believes that fixing them requires doing more throughout Latin America, not simply walling off the United States.

That’s an attitude that could put him at odds with other people in the president-elect’s circle of advisers when it comes to setting the Trump administration’s policy agenda — and, potentially, with Trump himself.

That could put Kelly at a significant disadvantage, as he tries to jostle for influence with the president-elect alongside harder-line immigration hawks like attorney general nominee Jeff Sessions (and Kansas Secretary of State Kris Kobach, who could be named Kelly’s own deputy). Furthermore, he’d be taking the reins of a department that’s never had its act together — with less experience managing civilian bureaucracy than his four predecessors at DHS, he’d be tasked with succeeding where they’ve failed.

Kelly once called domestic politics a “cesspool.” Now, how he navigates that cesspool — in the White House and in his department — could shape the futures of millions of immigrants (legal and unauthorized) and their families in the US. It could push more refugees to flee to the US (and determine whether they’re accepted or imprisoned once here) — or ensure they don’t have to leave to begin with. And it could determine whether the threats to American security that Trump hyped while running for president are actually quashed — or whether they continue to be exploited for political gain.

Kelly is a security hawk — but he’s more concerned with root causes than border walls

Trump and his transition team reportedly started taking a serious look at Kelly on the strength of the general’s testimony before the Senate Armed Services Committee in early 2015, when he was supervising the US military’s presence in Central and South America as head of US Southern Command (SOUTHCOM).

Kelly gained a reputation at SOUTHCOM as an outspoken critic of the Obama administration and Congress’s approach to Latin America — consistently calling for the government to devote more money, drones, and ships to the fight against the flood of refugees, drugs, and weapons from Latin America.

In front of the Senate, he accused Washington of ignoring the growing “existential threat” posed by insecurity to the country’s south.

“The relative ease with which human smugglers moved tens of thousands of people to our nation’s doorstep,” Kelly testified, shows that “these smuggling routes are a potential vulnerability to our homeland. As I stated last year, terrorist organizations could seek to leverage those same smuggling routes to move operatives with intent to cause grave harm to our citizens or even bring weapons of mass destruction into the United States.”

Kelly warned that Iran, Russia, and China are building relationships with Latin American governments, and that terrorist groups including ISIS are recruiting members in Caribbean nations that don’t have the law enforcement capacity to track them or prevent them from being smuggled into the US.

It’s easy to see what Trump finds appealing in this worldview. From the beginning of his campaign, the president-elect has said that the lack of security along America’s southern border encourages terrorism and crime.

Trump’s preferred solution, of course, is to build a “big, beautiful wall” at the US/Mexico border. As DHS secretary, Kelly would probably be the point person for actually building such a wall. But while Kelly has never explicitly come out against the wall — he told the Military Times earlier this year that he believes the country has a right to “some form of control, whether it’s a wall or a fence” — his analysis of the problem differs from his would-be boss’s in an important way: Kelly doesn’t think the border, per se, is the problem.

In the Military Times interview, Kelly went on to say, “If the countries where these migrants come from have reasonable levels of violence and reasonable levels of economic opportunity, then the people won’t leave to come here.” In an interview with Foreign Policy in July, he put it more bluntly: “No wall will work by itself.”

When Kelly criticized Washington for its lack of attention to Latin America, he was criticizing its lack of attention to the instabilities of the region itself — instability that was so overwhelming that no amount of US money or military might could fully stop the problems.

The border crisis of 2014, in which tens of thousands of unaccompanied children and mothers with children from Central America’s Northern Triangle (Guatemala, Honduras, and El Salvador) crossed into the United States and turned themselves in to border authorities seeking asylum, led the Obama administration to deepen its commitment to helping those countries. In particular, Kelly helped lead the Alliance for Prosperity in the Northern Triangle, which invested about $1 billion.

It’s an accomplishment he appears to be proud of. But he also appears to believe it was too little, too late — that the US needed to be thinking of border security as a problem of regional stability way earlier. He appeared to issue a subtle criticism of the response to the 2014 border crisis in his 2015 Senate testimony.

“Unless confronted by an immediate, visible, or uncomfortable crisis,” he testified, “our nation’s tendency is to take the security of the Western Hemisphere for granted. I believe this is a mistake.”

Kelly’s analysis of the problem differs sharply from some DHS agents who have Trump’s ear

This isn’t just a difference of philosophy. Different analyses of a problem lead to different proposed solutions. That’s certainly true when it comes to immigration, in which your answer to “Why are people coming or staying in the US illegally?” is a necessary prerequisite to answering “And how do we stop it?”

Most immigration hawks — including the leadership of the unions representing US Border Patrol and Immigration and Customs Enforcement, both of whose endorsements Trump trumpeted on the campaign trail — believe that lenient enforcement of immigration laws is a big reason that immigrants choose to come to the US illegally.

During the 2014 border crisis, for example, testimony from Border Patrol agents highlighted rumors that the US would grant amnesty to people who arrived before a particular date as a chief reason why so many children were entering the country. (Some observers interpreted that as a reference to the Deferred Action for Childhood Arrivals program that Obama had implemented for immigrants already in the US in 2012 — a program for which new arrivals wouldn’t be eligible, but which some immigration hawks argued had served as an enticement anyway.) As a result, they criticized the Obama administration for not doing more to detain and deport new arrivals — and not sending a strong enough message by deporting more unauthorized immigrants who were already here.

But Kelly did not agree with that assessment at all. “The decay of national institutions because of the drug trade has become a mess. The violence is very high, so investment is hard to come by, and so the economic opportunities are sparse, so people are on the move,” he told the Pacific Council last year with reference to the flow of unaccompanied children. “Frankly, they’re better off in our country. I’m not saying they should stay, but they’re better off here.”

On its own, that difference between Kelly and the personnel under his command could have implications for how the US treats asylum seekers and refugees — Trump and other conservatives have argued that the government is way too trusting of people who claim they’re in humanitarian danger. But it also has deeper implications for immigration policy.

Other members of Trump’s cadre of advisers — including Kansas Secretary of State Kris Kobach, who was himself floated as a potential DHS secretary and who, according to one report, may be appointed Kelly’s deputy — believe in “attrition through enforcement”: the idea that cracking down enough on unauthorized immigrants currently in the US will induce them to return to their countries of birth. But to people who believe that countries from which immigrants come are such disasters that the immigrants are “better off here,” that theory doesn’t look so sound — it seems less likely that any immigrant would choose to return to such a country.

At the same time, it’s not clear whether this is a battle Kelly wants to pick — especially because immigration agents are very good at making their displeasure with leadership known and are confident that they’ll be free to do their jobs the way they see fit under Trump. Who serves under Kelly in the department (especially if Kobach really is named deputy) will be an important sign of whether the general’s holistic approach or the crackdown-focused “attrition” approach will prevail.

Kelly is a non-bureaucrat getting thrown into one of the US government’s most dysfunctional bureaucracies

Who else is picked to serve under Kelly at DHS will be important — not just for policy but also for management.

In important ways, Kelly fills a hole in Trump’s growing cadre of policy advisers. He told Foreign Policy this summer that he’d be willing to serve under the next president no matter which party won the White House, because either candidate would "be in desperate need — and I mean desperate need — of military and foreign policy advice, because the world out there is just getting crazier and crazier."

He’ll now be one of those offering that type of advice to Trump, who comes to office without ever serving in elected office and with literally no experience with military. And unlike his fellow former generals (secretary of defense nominee James Mattis and National Security Adviser Michael Flynn), Kelly has managed to remain above partisan sniping so far, which makes him fairly well respected on the Hill.

But of the assets Kelly has for the position — his regional expertise (one source told Military Times that Kelly has “better relationships in Latin America than the State Department”), his military credibility, the searing pain of losing his own son in Afghanistan — he has no experience running civilian bureaucracies. (Kelly served as a “senior military adviser” to former Secretaries of Defense Robert Gates and Leon Panetta, but not as an executive or manager.)

As head of SOUTHCOM, Kelly learned (and complained mightily about) what budget constraints can do to security capabilities. But DHS’s problems go way deeper than budget constraints. DHS has arguably never been a functional Cabinet department over the 15 years of its existence.

The annual Inspector General report on DHS, which came out last month, basically said as much: “The promise of a unified Department — the purpose of its creation — has not yet been realized.”

While Kelly has some experience interacting with DHS and the border agencies as part of SOUTHCOM, he doesn’t have experience with FEMA (which famously fell apart under George W. Bush, though it’s been restored under Obama). His experience probably won’t help him with the TSA, which has been beset by security scandals and whose head of security was forced to resign this year after revelations that he’d paid himself $90,000 in bonuses despite said security scandals. It may or may not help Kelly fix the culture of the Secret Service, which was moved to DHS after 9/11 and was ensnared in scandal both for what its agents did under Obama (behave badly during presidential trips abroad) and for what they didn’t do (prevent intruders from entering the White House). And his experience with military command may not be enough to fix the department’s consistently low morale.

Outgoing Homeland Security Secretary Jeh Johnson has made management reform a priority of his tenure. But the 2016 Inspector General report warned that if “future leaders” lack the “focus, capability, or desire to engage in the often coercive task of culture change” — and if permanent changes to oversight and accountability weren’t “enshrined in law” — “the risk of DHS backsliding on the progress made to date is very real.”

Is John Kelly that sort of leader? It’s not clear.

To date, he’s deliberately avoided entering what’s derided as the “cesspool” of domestic politics out of a firm belief in the importance of maintaining the civil-military divide (a stark contrast with Flynn, who led chants of, “Lock her up!” at the Republican convention this summer). Now, he’ll be neck-deep in the “cesspool” — and the swirling media circus that the Trump presidency promises to be — with less experience handling it than they have.

Some of the biggest hot-button issues of Trump’s first 100 days — what he’s going to do with the Deferred Action for Childhood Arrivals program, whether and in what form he’ll institute a database to track visa holders from Muslim-majority countries, whether the wall will really be a wall or more of a fence — are going to flow through Kelly’s department.

It’s clear that Kelly won’t have a problem speaking his mind; it’s less clear how he’ll navigate the conflict many Trump allies end up facing between defending the incoming president’s policies and violating their own core beliefs.