I'm inclined to say that if you're only having fun for half an hour of a three-hour TTRPG session, something has gone very wrong? Not for nothing, I think, are TTRPGs part of the "hobby game" niche. Hobbies generally can include model assembly, gardening, cross-stitch, and so on, none of which are "fun" in the sense that we usually mean the term, but are clearly very engaging and rewarding for them as like it.
Or put another way, maybe when we talk about "fun" in RPGs, we mean something different from, say, the thrill of a roller coaster ride or a game of friend-or-foe tag.
(All that said, TTRPG play still ought to be fun, even with a more "hobby"-like sense of the term!)
Apropos of resource management and fun in TTRPGs, I'm confident to assert as fact that one can and will have engaging and rewarding gameplay with any given amount of resource management, from the most detail-oriented "how many fractions of a pint of oil did I just use in my lantern?" tracking to the most abstract die roll mechanic to almost none at all (*). I think two big factors are player tolerances/preferences and gameplay focus.
Apropos of player tolerances/preferences, different players are going to prefer different levels of management, either in and of itself or as befits the gameplay focus of the game. Well and good. We only run into problems when someone starts assuming their preference is "objectively" superior.
Apropos of gameplay focus, as others have noted upthread, plenty of players seem to enjoy managing resources such as hit points or spell slots while playing D&D, even as they chafe against managing torches or rations. The game's focus has been on heroic deeds and rich tactical combat - thematically since about the mid-1980s and mechanically since 3e came out - so managing the resources that facilitate that gameplay is intrinsically rewarding; managing resources that are orthogonal to such gameplay - torches, rations, and carrying capacity - is down to player preference.
Contrast that to pemerton's gameplay examples from Torchbearer, where players are quite clearly engaged by such minutiae as whether they even have shoes! The focus of more survival-oriented games drives engagement with such matters in a way that the focus of heroism-oriented games do not.
Of course, one thing about D&D in particular is that it inhabits a weird space where people want it to enable both heroic fantasy and survival-style play at once!
One thing I think also matters is how "solvable" a resource management problem is. Hit points are rarely a "solved" problem of resource management, for instance. Even if you play a 5-minute adventuring day, you can run out of hit points in that one encounter. Going hungry in Minecraft matters - up until you have set up your pen with animals and/or your fields of wheat and can always have stacks of food in your inventory, whereupon it ceases to be an interesting problem.
(*) I'm not referring to some sort of "god-mode" approach; say rather that there are TTRPGs where managing resources as such just isn't part of gameplay. I have yet to play, say, Monsterhearts (and probably won't), but I feel fairly confident saying that resource management, at least as it's being conceived of in this thread, just isn't part of the game at all, with the possible exception of managing your relationships with other player characters and NPCs and leveraging them to achieve your goals in gameplay. (I could, of course, be mistaken and would be happy to be corrected.) Superhero genre games are another example.