This an old and incorrect belief that largely derives from the difficulty of putting electrodes into their teeny, tiny neurons. Close relatives of C elegans that are larger (and hence more easily experimented on) do have action potentials, and for some neurons in C elegans, we also have good evidence of action potentials [1, 2]. Absence of evidence is not evidence of absence.
[1] Lockery SR, Goodman MB. The quest for action potentials in C. elegans neurons hits a plateau. Nat Neurosci. 2009 Apr;12(4):377-8. doi: 10.1038/nn0409-377. PMID: 19322241; PMCID: PMC3951993.
[2] Jiang, J., Su, Y., Zhang, R. et al. C. elegans enteric motor neurons fire synchronized action potentials underlying the defecation motor program. Nat Commun 13, 2783 (2022). https://doi.org/10.1038/s41467-022-30452-y