The US government has virtually no ability to "gift" any item to a foreign government - there must be accountability. So, let's take a decommissioned M1 tank. Were it sold to an ally as part of a military assistance contract the ally would pay that money to the US government. The ally would also likely buy a security assistance package which would contain spares and training. The Army would account for all of that as a military sale.
Therefore, that potential value is also assigned to the tank provided to Ukraine. In its case, rather than Ukraine writing a check, its theoretical sale value is deducted from the congressional DOD allocation for Ukraine.
However, there are 2,000 M1 tanks permanently parked at Sierra Army depot alone. This does not count the hundreds being withdrawn from the Marine Corps or sitting in other depots. There are very few buyers for these tanks and are unlikely to ever be many as they daily become more obsolete. Eventually, they will have to be demilitarized at great expense - a big driver of which is the composite armor which contains depleted uranium.
Therefore, in realty the tank provided to Ukraine is actually not a "lost" sale, but is quite likely an avoided expense. The same is true of older munitions.