It is dependent on case, yes.
If 'the sons' are the subject of the sentence (the ones doing the 'action') then filii is used (the verb will also be in a 3rd person plural form).
filios will be used when 'the sons' are the direct object (the ones being directly 'affected' by the verb). In this sentence, filios is used since they are 'had'. The verb ending of habemus tells us that 'we' are the subject.
We can think of it as the difference between THEY the sons ( = filii), serving as the subject of a verb (the ones who do something, or are something); and THEM the sons ( = filios), serving as the object (of the verb: direct object; or of certain prepositions). We SEE them, we LOVE them, we HELP them, etc., are all examples of "filios" (them, the sons) used as a direct object.