CCP 998 applies when the parties settle after the time for accepting the 998 offer expires and the settlement amount is less than the amount of the 998 offer–at least when the eventual settlement fully resolves all claims in the case and provides for eventual dismissal of the action after any award of attorney fees and costs is entered by the trial court.