(CNN) As Republicans prepare to marshal all available resources for what is expected to be a difficult midterm battle, White House aides are advising President Donald Trump on where to leverage his star power based in part on how loyal candidates have been to him.

White House officials are scrutinizing various ways Republicans have backed Trump both before and after the 2016 election. Aides have been emphasizing the loyalty or disloyalty of candidates when counseling Trump on which primary races he should intervene in and which he should avoid.

While several sources cautioned that a number of other factors -- including the vulnerability of the candidate, "door metrics," polling and organization -- play into decisions about resources, Trump has also considered what one White House aide described as "the broader loyalty question."

One senior White House official said the political team is applying three broad questions to each incumbent Republican who seeks Trump's support: whether the candidate backed Trump after the Indiana primary, whether the candidate got on board with Trump's candidacy after the GOP convention and whether the candidate was supportive of Trump after he won the 2016 election.

Republicans who have criticized the President aren't necessarily crossed off the list of people Trump might help, the senior official noted. Instead, the political team is poring over the negative things Republicans have said about Trump and weighing the context, tone and frequency of any jabs, the senior official said.

"Loyalty is very important to him" when it comes to picking who to support in GOP primaries, another senior White House official said.

Endorsement by tweet

Trump flexed his political muscle on Tuesday when he tweeted endorsements for Rep. Devin Nunes and House Majority Leader Kevin McCarthy, both of whom are on primary ballots in California on Tuesday, as well as Mississippi's Sen. Roger Wicker, who headed into Tuesday's primaries with a nominal challenge.

A source with knowledge of the endorsement said Nunes, who is fighting for re-election in a competitive district, did not directly ask Trump for the endorsement. McCarthy is close enough to Trump that he has been floated as a possible White House chief of staff and Wicker is also perceived as supportive of Trump.

Notably, Trump's foray into the California primaries did not involve an endorsement for Rep. Dana Rohrabacher, another struggling incumbent Republican. Rohrabacher's GOP primary opponent has used a recorded comment the congressman appeared to have made in March 2016 calling Trump a "mean, nasty SOB" as campaign fodder.

In December, Trump effectively tweeted an endorsement of one of his closest congressional allies -- Rep. Ron DeSantis -- in Florida's GOP gubernatorial primary despite the party's general policy of staying out of primaries when an incumbent isn't running.

"Congressman Ron DeSantis is a brilliant young leader, Yale and then Harvard Law, who would make a GREAT Governor of Florida. He loves our Country and is a true FIGHTER!" Trump tweeted.

While Senate Majority Leader Mitch McConnell and House Speaker Paul Ryan do weigh in on who the President should back, the source said their advice often "gets filtered through Johnny DeStefano."

DeStefano oversees the White House Offices of Personnel, Political Affairs and Public Liaison, and the source said some conservatives in and out of the White House think he has pushed the President too far in a "swampy" direction when it comes to primary endorsements.

"Johnny's natural inclination is to run to the establishment side of things and then put it in a narrative of, 'This person supports you or doesn't support you,' and accentuates the negatives if any negative comments have been made about the President and de-emphasizes the negative comments for his chosen candidates," the source added.

A comprehensive look

White House officials argued that each incumbent seeking a boost from Trump receives a comprehensive look at their record and needs, and denied that DeStefano or other senior aides have attempted to manipulate the President into endorsing leadership's chosen candidates.

People close to the President have long described Trump as someone who prioritizes loyalty. The White House has struggled to fill dozens of vacant positions across the administration due to the requirement that prospective hires have a track record of fealty toward Trump.

One White House aide noted that, while the political team wants to prioritize "friends" of the President when making decisions about who to help, the situation for Republicans this year is too perilous to exclude everyone who has ever broken with Trump.

"At the end of the day, we want to keep the House majority as much as anyone, so we're going to do whatever it takes," the White House aide said.

Another senior White House official described the process of determining which incumbents to endorse as twofold: qualitative and quantitative. While the latter process is based on hard data like fundraising levels and the number of doors a campaign has knocked on, the qualitative process is a "more art than science evaluation," the senior official said.

"It's more holistic," the senior official said of qualitative factors the White House considers. "In addition to loyalty, has this person been checking in with the White House, is there good organization, are they really helping themselves get re-elected?"

Not mandatory

JUST WATCHED Grimm runs for old seat after prison time Replay More Videos ... MUST WATCH Grimm runs for old seat after prison time 02:04

Indeed, although some aides may be using loyalty as a way to steer Trump's decisions, loyalty has not appeared to be a mandatory criterion for the handful of endorsements he has made so far.

For example, Trump threw his weight behind Rep. Dan Donovan -- a Republican running for re-election in New York against his predecessor, Michael Grimm -- last week despite Donovan's refusal to vote for two of Trump's top legislative priorities: Obamacare repeal and the tax bill.

The President hinted that Grimm -- who did a stint in prison following his resignation from New York's 11th Congressional District seat in 2014 after pleading guilty to tax evasion -- couldn't help Republicans hold on to the seat in a general election. Alluding to the political disaster that unfolded in the Alabama US Senate race last year after Republicans nominated Roy Moore, Trump said New Yorkers should vote for Donovan because the GOP "can't take any chances on losing to a Nancy Pelosi-controlled Democrat."

Trump faces pressure to back Rep. Martha Roby, who has strongly criticized him, if her GOP challengers force her to a runoff in her primary on Tuesday, two sources said.

The Alabama conservative withdrew her endorsement of Trump in October 2016 after the publication of the infamous "Access Hollywood" tape that captured Trump making lewd remarks about women that surfaced a month before the election. Her opponents have used what she said at the time to characterize her as insufficiently loyal to the President.

A House GOP campaign aide said that many Republicans facing tough primary or general re-election battles have already entreated Trump for his support.

"I think a lot of these candidates, they recognize the power of a tweet, endorsement can have for them," the aide said. "If they have the opportunity, they do try to get in his ear, to get that support."

The House campaign aide noted that while there have been no dramatic differences so far between Republican groups such as the National Republican Congressional Committee and the White House during primary season, the likelihood of any potential disagreements will plummet once general elections are underway in the fall and Republican nominees are set in stone.

"Come the general, all these races, I think the White House will be very much in lockstep with us," the aide said.