Remove partial matching duplicate lines and retain longest line

JavaScript (ES6),  85 82  79 bytes

a=>a.sort((a,b)=>-!b[a.length]).filter(s=>a[k=/reminder \d+/.exec(s)]^(a[k]=1))

Try it online!


We first sort all strings from longest to shortest.

a.sort((a, b) =>
  -!b[a.length]  // 0 if 'b' is longer than 'a', -1 otherwise

We then filter the strings, keeping only the first occurrence of each reminder N key. The underlying object of the input array a[] is re-used to keep track of the keys that were already encountered.

.filter(s =>
  a[k = /reminder \d+/.exec(s)]
  (a[k] = 1)

Japt, 20 bytes

Takes input as an array of strings. Output is sorted by the matched number, in lexicographical order.

ü_f`ã„ %d+` gîñÊÌ

Try it (Header splits input string on newlines)

ü_f`... %d+` gîñÊÌ     :Implicit input of array
ü                       :Group and sort by
 _                      :Passing each through the following function
  f                     :  Match
   `... %d+`            :    Compressed string "reminder %d+", which translates to the RegEx /reminder \d+/g
             g          :  Get first match ('Cause matching returns an array)
              Ã         :End grouping
               ®        :Map
                ñ       :  Sort by
                 Ê      :    Length
                  Ì     :  Get last element

Python 3.8, 134 132 bytes

import re
def f(l,d={}):
 for s in l:
  if len(d.get(n:=re.sub('.*reminder (\\d+).*','\\1',s))or'')<len(s):d[n]=s
 return d.values()

Try it online!

Tried recursive lambda approach but it's longer:

Python 3.8, 148 bytes

f=lambda l,d={}:l and(len(d.get(n:=re.sub('.*reminder (\\d+).*','\\1',s:=l.pop()))or'')<len(s)and d.update([(n,s)])or f(l,d))or d.values()
import re

Try it online!