At the time, farmers were plagued with soaring energy prices, rolling blackouts, low rainfall and low-cost food imports flooding the market. Gray worked on legislation to get rid of the so-called “Tractor Tax,” exempting farm equipment and the fuel to power them and farming machinery from state sales taxes. This exemption encouraged farmers to trade in aging farm equipment for safer, more efficient and cleaner-running tractors, trucks and other vital machines. Gray spent 15 years as a staff member for elected leaders including Cardoza, Herb Wesson, Fabian Nunez and Jerome Horton. In this time, Gray helped develop legislation to provide tax incentives to small businesses, protect groundwater from the dangers of fracking and protect family farms from scrap-metal theft. Gray worked on legislation to provide tax credits to first-time homebuyers and protect homeowners against fraudulent loan modification scams in the aftermath of the collapse of the home-buying bubble, which devastated property values in his district. Gray was also a member of the staff of state Sen. Ron Calderon, D-Montebello. In July 2013, Gray testified in the federal investigation involving the corruption charges against Calderon. Gray was elected to the California State Assembly in November 2012, receiving 58.2% of the vote. In the 2014 primary election, Gray received 95.3% of the vote and was reelected in 2016 with 66.8% of the vote and again in 2018 with 71.3% of the vote. He chairs the Governmental Operations Committee and sits on the Agriculture Committee, the Revenue and Taxation Committee and the Select Committee on Health Care Access in Rural Communities. Gray is also a member of the Joint Legislative Committee on Emergency Management, which has played a leadership role in the response to the Coronavirus outbreak. In October 2013, when a fire destroyed the power source for a mobile home park in the tiny community of Santa Nella, Gray organized efforts to restore power to 30 homes by bringing together local electrical workers and donated parts. In June 2014, Gray helped organized a bipartisan group, including Republican Senator Anthony Cannella and Merced Superintendent of Public Schools Steve Gomes, to ensure state funding could be found to build a new special-education school in Merced County. Gray was the honored special guest when the project broke ground on August 15, 2014. In July 2014, Gray helped bring attention to Merced and Stanislaus counties as a potential site for Tesla Motors' multibillion-dollar “Giga-Factory,” focusing on two languishing former military bases in Atwater and Patterson, California.