as much as (one) could do (not) (to do something)
A phrase used when one struggles to do something. It can include "not" when one is trying to avoid doing something. It was as much as I could do to keep from crying when the teacher yelled at me in front of the whole class. It was as much as I could do not to start laughing when my three-year-old told my boss she looked like a "meanie."
as much as somebody can/could ˈdo (not) to do something
used to say that something is/was difficult to do: No dessert for me, thanks. It was as much as I could do to finish the main course.