So if a bonus action like shield bash says "you can do it as a bonus action when you make a melee attack" and you use the bonus action before you make the melee attack, by your logic, does this mean you still have the opportunity to cast a spell instead based off the result if the shield bash?
No, and that's not at all similar to what we're talking about, either.
Focus on the triggers for each of these two reactions as that is extremely important here.
You can use one reaction a turn, and whether you use that reaction is determined whenever a trigger for a reaction you have available occurs. If you don't use it for one trigger, it can later be used for another trigger.
Consider this scenario: You have two hostile creatures adjacent to you. One of them moves away from you. This presents the trigger for an opportunity attack. If you choose not to take an opportunity attack against this creature, you still have your reaction available. Then the second creature moves away from you. This presents the trigger for an opportunity attack. Since you didn't use the reaction when the first creature moved away, the first time a trigger was presented, you can still use it now. You could still choose not to use your reaction now to have it available for another effect. If you do use it now, you can't use it on a later effect.
The scenario in OP is similar but a little different as there is a branching decision tree, rather than a linear decision tree.
You make a dexterity saving throw and the effect casing the saving throw deals elemental damage, there are two significant branches that are separate from each other: succeed or fail on the saving throw.
1. You succeed the dexterity saving throw.
a. This presents the trigger for the reaction of shield master's third benefit.
b. If you choose to use your reaction for shield master, you take no damage.
c. If you choose to not use your reaction for shield master, you still have your
reaction available.
i. Since you didn't use shield master, you take half damage from the effect.
ii. This presents the trigger to cast absorb elements.
iii. If you choose to use your reaction for absorb elements, you gain resistance to the
triggering damage.
iv. If you choose not to use your reaction for absorb elements, you still have your reaction available.
2. You fail the dexterity saving throw.
a. You take elemental damage.
b. This presents the trigger for casting absorb elements as a reaction.
c. If you choose to use your reaction for absorb elements, you gain resistance to the triggering damage.
d. If you choose not to use your reaction for absorb elements, you still have your reaction available.